Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<!DOCTYPE html>
<script src=""></script>
<script src=""></script>
<script src=""></script>
$.validator.addMethod("mustbeyoungerthan", function(value, element) {
var max = $(element).attr('data-rule-mustbeyoungerthan');
if (parseInt(value) > parseInt(max))
return false;
return true;
}, "Default error message.");
<h1>Form Validation Example</h1>
<form id='registerForm' name='registerForm' method='post' action='' class="validate" >
Name: <input type='text' name='name' id='name' class='required' />
Email: <input type='text' name='email' id='email' class='required' />
Age: <input type='text' name='age' id='age' data-rule-mustbeyoungerthan="50" data-msg-mustbeyoungerthan="Invalid age range."/>
<input type='submit' name='Submit' value='Submit' />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.