CraigH
08-25-2007, 12:43 AM
Hello all,
I've seen the posts on this, but the submit button is not disabling on my page. The code is supposed to check the form for errors and disable the submit button. It catches the errors, but won't disable the submit. Here's the JS in the head:
function disableForm(theform) {
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; i++) {
var tempobj = theform.elements[i];
if (tempobj.type.toLowerCase() == "submit")
tempobj.disabled = true;
}
// setTimeout('alert("Sending information...")', 2000);
return true;
}
}
function validRequired(formField,fieldLabel)
{
var result = true;
if (formField.value == "")
{
alert('Please enter a value for the "' + fieldLabel +'" field.');
formField.focus();
result = false;
}
return result;
}
function validateForm(theForm){
if (!validRequired(theForm.cardnumber,"Credit Card Number")){
return false;
}
if (!validRequired(theForm.cardexpmonth,"Expiration Month")){
return false;}
if (!validRequired(theForm.cardexpyear,"Expiration Year")){
return false;}
disableForm(theForm);
return true;
}
Here's the form line:
<form name="addjob3" action="<? PHP_SELF; ?>" method="POST" onsubmit="return validateForm(this)">
Here's the submit button:
<input type="submit" name="submitp" value="Submit">
Thanks in advance!
I've seen the posts on this, but the submit button is not disabling on my page. The code is supposed to check the form for errors and disable the submit button. It catches the errors, but won't disable the submit. Here's the JS in the head:
function disableForm(theform) {
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; i++) {
var tempobj = theform.elements[i];
if (tempobj.type.toLowerCase() == "submit")
tempobj.disabled = true;
}
// setTimeout('alert("Sending information...")', 2000);
return true;
}
}
function validRequired(formField,fieldLabel)
{
var result = true;
if (formField.value == "")
{
alert('Please enter a value for the "' + fieldLabel +'" field.');
formField.focus();
result = false;
}
return result;
}
function validateForm(theForm){
if (!validRequired(theForm.cardnumber,"Credit Card Number")){
return false;
}
if (!validRequired(theForm.cardexpmonth,"Expiration Month")){
return false;}
if (!validRequired(theForm.cardexpyear,"Expiration Year")){
return false;}
disableForm(theForm);
return true;
}
Here's the form line:
<form name="addjob3" action="<? PHP_SELF; ?>" method="POST" onsubmit="return validateForm(this)">
Here's the submit button:
<input type="submit" name="submitp" value="Submit">
Thanks in advance!