I am trying to setup validation using the $('#form').validate. most examples use document.ready for this. since my page is dynamically loaded I cant use document.ready.
Also most examples of $(#div).on('event') use the click event, is it possible to bind the 'load' event?
<div id="DivWhichIsntLoadedDynamically">
<div id="DynamicallyLoadedDiv">
<form id="myform">
<input type="text" name="entry[email]" /> <br/>
<input type="text" name="field2" /> <br/>
<input type="submit" />
</form>
</div>
</div>
$('#DivWhichIsntLoadedDynamically').on('load', function () {
alert('div load');
$('#myform').validate({
rules: {
'entry[email]': {
email: true
},
field2: {
equalTo: '[name="entry[email]"]'
}
},
submitHandler: function(form) { // for demo
alert('valid form');
return false;
}
});
});
updated fiddle: http://jsfiddle.net/JCY2E/8/