JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/jquery.validate.min.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<form id="myForm">
<input type="text" name="field1" />
<br/>
<input type="text" name="field2" />
<br/>
<input type="submit" />
</form>
<a id="docs" href="http://docs.jquery.com/Plugins/Validation" target="_blank">Validation Documentation</a>
CSS
#docs {
display: block;
position: fixed;
bottom: 0;
right: 0;
}
JavaScript
$(document).ready(function () {
$("#myForm").validate({ // initialize the plugin
// any other options,
onkeyup: false,
rules: {
field1: {
required: true,
minlength: 5
},
field2: {
required: true,
minlength: 5
}
}
});
$("#myForm").ajaxForm({ // initialize the plugin
// any other options,
beforeSubmit: function () {
return $("#myForm").valid(); // TRUE when form is valid, FALSE will cancel submit
},
success: function (returnData) {
alert('form submission'); // for demo
//$('#content').html(returnData); // for demo
}
});
});