Hi,
Using ASP.NET MVC jquery remote validation features and posted a problem I have over on
www.asp.net. My problem seems to be a jquery issue so adviced to check with this forum. My original problem is posted at
http://forums.asp.net/t/1644839.aspx but in summary I am using unobtrusive validation to call some remote code to check a username for duplicates.
Initially the username is checked when I remove focus from the field as expected, but once a validation error has occurred the remote method is being called for every keypress in the username field. I would rather it just called out once each time focus was shifted from the field. The generated HTML form is shown below.
Any help appreciated.
Thanks,
Richard
- <form action="/Account/Register" method="post"> <div>
<fieldset>
<legend>Account Information</legend>
<div class="editor-label">
<label for="UserName">User name</label>
</div>
<div class="editor-field">
<input data-val="true" data-val-remote="This username has already been taken" data-val-remote-additionalfields="*.UserName" data-val-remote-url="/Account/CheckUserName" data-val-required="The User name field is required." id="UserName" name="UserName" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="UserName" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="Email">Email address</label>
</div>
<div class="editor-field">
<input data-val="true" data-val-required="The Email address field is required." id="Email" name="Email" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="Email" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="Password">Password</label>
</div>
<div class="editor-field">
<input data-val="true" data-val-length="&#39;Password&#39; must be at least 6 characters long." data-val-length-min="6" data-val-required="The Password field is required." id="Password" name="Password" type="password" />
<span class="field-validation-valid" data-valmsg-for="Password" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="ConfirmPassword">Confirm password</label>
</div>
<div class="editor-field">
<input data-val="true" data-val-equalto="The password and confirmation password do not match." data-val-equalto-other="*.Password" id="ConfirmPassword" name="ConfirmPassword" type="password" />
<span class="field-validation-valid" data-valmsg-for="ConfirmPassword" data-valmsg-replace="true"></span>
</div>
<p>
<input type="submit" value="Register" />
</p>
</fieldset>
</div>
</form>