views:

83

answers:

1

This form works in Safari. In IE, it mostly works, but I get an error "Object doesn't support this property or method." on line 240.

In Firefox, no alert box appears, but the following error appears in the error console:

Error: myform is not defined Line: 240 (line 240 is below, starting with the word if)

<script type="text/javascript">
// Validate the form
// Confirm with the visitor the amount he entered is correct
// Submit if OK is pressed
$(document).ready(function() {
    $("#myform").validate({
        submitHandler:function(form){
            if(confirm("Please confirm your donation of $"+ myform.x_Amount.value + " to us.")){
                form.submit();
            }
        }
    });
});

// Put grey "no spaces" example text in the credit card number field
$('#x_Card_Num').example('(NoSpaces)', {
  className: 'greydefaulttext'
});
</script>

Guess I need to define myform.x_Amount.value. Have tried doing this in various ways but haven't stumbled across the right location to define it yet, or even the right syntax. Thanks for any help.

Update: Thanks to fresh eyes from RC and Bobince, it was simply a typo: myform.x_Amount.value should be named form.x_Amount.value - it now works in all browsers.

A: 

"submit is not a function" means that you named your submit button or some other element submit. Rename the button to btnSubmit and your call will magically work.

When you name the button submit, you override the submit() function on the form.

source

that fixes your one error. If by form.x_Amount.value you want to get the value of a textfield, try it like this:

document.form_name.element_name.value;

tutorial

CrazyJugglerDrummer
Thank you CJD, this indeed resolved the second error "Error: form.submit is not a function".
ANE
Would also like to give Bobince credit for figuring out the first error "not defined" (it was just a typo).
ANE