I am using jQuery validate for validate an input. My code:
$(\'#button\').click( function() { $(\"#form\").validate({ rules: {
Just add .form() to manually trigger the validation immediately (the default behavior waits for a submit event):
$('#button').click( function() { $("#form").validate({ rules: { phone: { required: true, number: true, rangelength: [7, 14] } } }).form(); });