Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can add custom validation for popup editing within the dataSource of your grid.</p> <pre><code>var dataSource = new kendo.data.DataSource({ transport: { ... }, schema: { model: { id: "UserName", fields: { UserName: {} Password: {} ConfirmPassword: {} Company_Name: {} First_Name: {} Last_Name: {} Address1: { validation: { minLength: function (input) { if (input.is("[name=UserName]")) { return input.val().length &gt;= 6; } return true; }, match: function (input) { if (input.is("[name=ConfirmPassword]")) { return input.val() == $("#Password").val(); } return true; } } } } } } }); </code></pre> <p>There are a few things to respect: The validation runs for <strong>ALL</strong> input elements within your popup, therefore</p> <ol> <li>you only have to define it for <strong>ONE</strong> of the fields in your model. Which one does not matter.</li> <li>you have to check which input element is checked in the current run, which does the if statement in my example.</li> <li>you have to append a <code>return true</code> at the end of each and every rule you define or otherwise you'll get an error message for every input you're not explicitly checking. If there's no return value passed, kendo automatically assumes the check had a false result.</li> </ol> <p>Every validation rule needs its own validation message or otherwise your validation tooltip box will only display a warning logo without any text. You can add it as an html attribute (<em>data-{validation rule}-msg</em>) in your input elements, like this:</p> <pre><code>&lt;input type="text" name="UserName" id="UserName" class="k-input k-textbox" required maxlength="8" pattern="[a-zA-Z0-9]+" validationMessage="Please enter username" data-minLenght-msg="Username must be at least 6 characters"/&gt; &lt;input type="password" id="ConfirmPassword" name="ConfirmPassword" class="k-input k-textbox" required validationMessage="Please enter Confirm Password" data-match-msg="Password and confirmation must be equal"/&gt; </code></pre> <p>Hope this helps</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload