I am using jQuery validation to validate input. My code is:
$('#button').click( function() {
$("#form").validate({
rules: {
phone: {
required: true,
number: true,
rangelength: [7, 14]
}
}
});
});
And HTML:
<form id="form" name="form" method="post" action="">
<input id="phone" name="phone" class="required" type="text" />
<div class="button" id="send_b">Send</div>
</form>
This code does not work. If I add this jQuery line
$("#form").submit();
inside the click event it works. But I don’t want to submit the form, so I just want to do a check by clicking.
Does anyone know how to do this?
source
share