Reputation: 27384
I have a form with validation using jQuery validation. This works perfectly however, my form always contains default values:
<input type="text" value="0" name="myname" class="required number error">
When a user first changes the values in the input boxes, no validation occurs until the input loses focus. After this first time any keyup / change event inside the input will result in validation.
How can I force the validation to occur on keyup / change ALL the time as opposed to after an initial change.
Upvotes: 1
Views: 2408
Reputation: 4571
As a quick answer put $('#yourForm input, #yourForm select').live('keyup change', function(e) { })
listener to your form and then check if it's the first time input is affected, and then force validate it by $('#yourForm").validate();
Upvotes: 0
Reputation: 11
Try this block after the .validate()
function:
$('input').keyup(function(){
if(!$(this).valid()){
return false;
}
});
Upvotes: 1
Reputation: 46178
Could you put your js part for the validate()
initialisation ?
Did you try something like
$('#your_form input').keyUp(function () {
$(this).parents('form').validate();
});
Upvotes: 0