Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

124 lines (111 sloc) 4.052 kB
<!DOCTYPE HTML>
<html>
<head>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="formwarden.js" type="text/javascript"></script>
<script src="jquery.formwarden.js" type="text/javascript"></script>
<style>
.invalid input, .invalid select, .invalid textarea{
border:solid 2px #f00;
}
.invalid{
color:#f00;
}
</style>
</head>
<body>
<form method="post" action="validation_only.html" >
<p>
<label>Email: <input type="text" name="email" /></label>
</p>
<p>
<label>First Name: <input type="text" name="firstName" /></label>
</p>
<p>
<label>UserName: <input type="text" name="userName" /></label>
</p>
<p>
<label>InnCode: <input type="text" name="inncode" /></label>
</p>
<p>
<select name="select">
<option value="">select one...</option>
<option>abc</option>
<option>def</option>
</select>
</p>
<p>
<select multiple name="multi">
<option>aaa</option>
<option>abc</option>
<option>def</option>
</select>
</p>
<p>
<input type="radio" name="radio" value="1" /> Choice 1
<input type="radio" name="radio" value="2" /> Choice 2
</p>
<p>
<input type="checkbox" name="check" value="1" /> Choice A
<input type="checkbox" name="check" value="2" /> Choice B
</p>
<p>
<label>Number of Things</label>
<input type="text" name="numOfThings" />
<input type="text" name="numOfThings" value="" />
</p>
<p>
<textarea name="textarea"></textarea>
</p>
<ul class="validation_summary">
</ul>
<input id="submit_button" type="submit" value="Go" name="submit_button"/>
</form>
<script type="text/javascript">
$(function(){
var validationOptions=
{
//override the error processing
/*
processErrors: function(results){
for(var item in results.fields){
var thing = results.fields[item];
if (!thing.valid){
alert(thing.error);
}
}
},
*/
//disable/enable blur
//enableBlur:false, //defaults to true
//provide custom validators if desired
//specify the validation summary container to use
// validationSummary: ".validation_summary" ,
before: function(form){ console.log(form)},
after: function(results){console.log(results)},
validators : {"inncode":function(value){return value.match(/^\d{5}$/);}}, //not required
fields:{
"inncode":[{isValid:"required", message:"Inncode is required"},
{isValid:"inncode", message:"Inncode must be 5 digits"}],
"userName":[{isValid:/^[a-z]{3,}?$/i, message:"UserName must be greater than 3 characters and not include any numbers"},
{isValid:"required", message:"UserName is required"}],
"email":[{isValid:"required", message:"Email is required"},
{isValid:"email", message:"Email must be valid"}],
"numOfThings":[{isValid:"required", message:"Number of Things is required"}],
"firstName":[{isValid: "required", message: "First Name is required"},
{isValid:function(value, form){ return value.length < 25; }, message:"First Name must be less than 25 characters"}],
"select":[{isValid: "required", message: "Select is required"}],
"radio":[{isValid: "required", message: "radio is required"}],
"check":[{isValid: "required", message: "check is required"}],
"multi":[{isValid: "required", message: "multi is required"}],
"textarea":[{isValid: "required", message: "textarea is required"}]
}
,beforeSubmit: function(){
return confirm("Everything is valid proceed with submit?");
}
};
$("form").validation(validationOptions);
});
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.