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://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/additional-methods.js"></script>
<div id="content"></div>
<button>Click Me</button>
<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 () {
function runAjax() {
$.ajax({
url: 'test',
success: function (data) { // crude simulation of ajax load
$('#content').html('<form id="myform"><input type="text" name="field1" /><br/><input type="text" name="field2" /><br/><input type="submit" /></form>');
},
complete: function () {
$('#myform').validate({ // initialize the plugin
rules: {
field1: {
required: true
},
field2: {
required: true
}
}
});
}
});
};
$('button').click(function () {
$(this).remove();
runAjax();
});
});