Hi - I'm having what I hope is a simple-to-fix issue.
Basically, I've got one block of javascript containing the function, and then I'm trying to call it from another block of javascript (within a jQuery $(document).ready function). Whilst it works fine on Firefox, I get an 'Object Expected' error in IE7. It's probably something to do with scope, but I'm not sure what to fix. Firebug doesn't seem to give any light on the subject.
So, here's my function:
<script type="text/javascript">
//<![CDATA[
function onsite_validate(){
$("#tsp_onsite_form").validate({
errorClass: "form_error",
errorElement: "em",
errorPlacement: function(error, element) {
error.prependTo( element.parent("label") );
},
highlight: function(element, errorClass) {
$(element).addClass(errorClass);
},
unhighlight: function(element, errorClass) {
$(element).removeClass(errorClass);
},
rules: {
fault_found: "required"
},
messages: {
fault_found: "was a fault found?"
},
submitHandler: function(form) {
$.blockUI();
form.submit();
} //ends submit handler
});
}
//]]>
</script>
and after this, I have the following:
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
onsite_validate();
});
//]]>
</script>
The 'Object Expected' error throws on calling onsite_validate();
I'm sure I'm making a fundamental mistake - just can't seem to spot it!
Many thanks