Created
May 22, 2015 12:29
-
-
Save gilesbradshaw/56925d916d4720421840 to your computer and use it in GitHub Desktop.
simple jquery valuidate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title></title> | |
<script src="Scripts/jquery-1.9.1.js"></script> | |
<script src="Scripts/jquery.validate.js"></script> | |
<script> | |
$().ready(function () { | |
jQuery.validator.addMethod("mustBeGiles", function (value, element) { | |
return this.optional(element) || value=="giles"; | |
}, "should be giles!!!"); | |
$("#testForm").validate({ | |
rules : { | |
giles: { mustBeGiles: true } | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<form id="testForm"> | |
<label for="min2">min2</label> | |
<input id="min2" type="text" minlength="2" > | |
<label for="min3">min3</label> | |
<input id="min3" type="text" minlength="3" > | |
<label for="giles">giles</label> | |
<input name="giles" id="giles" type="text" > | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment