I am using jQuery validate for validate an input. My code:
$('#button').click( function() {
$("#form").validate({
rules: {
phone: {
required: true,
number: true,
rangelength: [7, 14]
}
}
});
});
And the 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 is not working. If I add this line of jQuery
$("#form").submit();
inside the click event it works. But I don't want to submit the form so I want just to make the validation on click.
Does anyone know how to do this?