JSFiddle - React, Tailwind, and code Playground
by berandorFiddle
HTML
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<html>
<body>
<form id='foo'>
<input name='not this one' type="text" />
</form>
<form id="bar" >
<label for="name" >Name (*)</label>
<input name="name" /><br/>
<label for="email" >Email (*)</label>
<input name="email" /><br/>
<input type="button" value="Submit"/>
</form>
</body>
</html>
JavaScript
$(function() {
$('input[type=button]').live('click', function() {
$('#bar').validate(
{
rules: {
name: { required: true },
email: { required: true }
},
messages: {
name: "<br />Name is required",
email: "<br />Email is required"
}
});
if ( ! $('#bar').valid() )
{
alert('not valid');
}
});
});