if($('#error-email-id').val() === '' ||
($("#error-email-id").val()) === 'Please enter email ID' ||
(!filter.test($("#error-email-id").val())) )
{
here I want that the the 开发者_开发技巧value in the field remains "Please Enter email id". But When I enter wrong id say "afafaf.com" then after validating it remains "afafaf.com" But I want if it fails the validation it should be "Please Enter email id"
return false;
}
You can set the value using .val(value) method
$("#error-email-id").val("Please enter email ID");
Then just set it as value:
if( /* ... lots of conditions here ... */) {
$("#error-email-id").val('Please enter email ID');
return false;
}
See the documentation of .val().
Assign it explicitly inside your validation
$("#error-email-id").val('Please enter email ID')
加载中,请稍侯......
精彩评论