Fetching contributors…
Cannot retrieve contributors at this time
124 lines (111 sloc) 3.96 KB
<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>
.invalid input, .invalid select, .invalid textarea{
border:solid 2px #f00;
<form method="post" action="validation_only.html" >
<label>Email: <input type="text" name="email" /></label>
<label>First Name: <input type="text" name="firstName" /></label>
<label>UserName: <input type="text" name="userName" /></label>
<label>InnCode: <input type="text" name="inncode" /></label>
<select name="select">
<option value="">select one...</option>
<select multiple name="multi">
<input type="radio" name="radio" value="1" /> Choice 1
<input type="radio" name="radio" value="2" /> Choice 2
<input type="checkbox" name="check" value="1" /> Choice A
<input type="checkbox" name="check" value="2" /> Choice B
<label>Number of Things</label>
<input type="text" name="numOfThings" />
<input type="text" name="numOfThings" value="" />
<textarea name="textarea"></textarea>
<ul class="validation_summary">
<input id="submit_button" type="submit" value="Go" name="submit_button"/>
<script type="text/javascript">
var validationOptions=
//override the error processing
processErrors: function(results){
for(var item in results.fields){
var thing = results.fields[item];
if (!thing.valid){
//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
"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?");