Validating after load()
Validating after load()
I'm experimenting with the load() function. It works fine except when I try to validate (using jQuery Validate).
I have a page called "index.php" which contains the bulk of my code (including the jQuery validate call). The load function calls in a div from another page which we'll call foo.php. The page loads fine, but it just won't validate. I've wondered if you simply can't validate a "load"ed page, but I find that hard to believe. Here's my code:
In index.php:
$(document).ready(function() {
$('#navCol a').click(function() {
$('#theForm').load($(this).attr('href').replace('#', ' #'));
return false;
});
$('label.required').append(' <strong>*</strong> ');
var v1 = $('#form1').validate({
errorClass: "warning",
onkeyup: false,
onblur: false
});
});
And from foo.php:
<div id="part1" class="ui-state-default ui-corner-all formpadding">
<h4>Location</h4>
<div class="ui-widget ui-form ui-widget-content ui-corner-all">
<form id="form1" class="ui-helper-clearfix">
<label for="street" class="required">Listing Address:</label>
<input type="text" name="street" id="street" class="required" maxlength="128" size="30" /><br />
<label for="citystate" class="required">Listing City, State:</label>
<input id="citystate" name="citystate" class="required" maxlength="150" size="30" /><br />
<input class="buttonfix ui-helper-clearfix" type="submit" value="Save and Continue" />
</form></div>
</div>
If anyone has any suggestions it would be greatly appreciated.
Thanks!