How do I read the Value of the submit Button

J

jb

this is what I have in my funtion, but returns undefind value?

if (document.forms[0].submit.value=="Cancel") {
return true;
}
 
M

Martin Honnen

jb said:
this is what I have in my funtion, but returns undefind value?

if (document.forms[0].submit.value=="Cancel") {
return true;
}

Give the button a name
<input type="submit" name="submitButton"
then you can read
document.forms[0].elements.submitButton.value
 
J

jb

I tryed what you gave me, still same results here my function, it all works
except for the part that checks the submitBut value; always reture an
undefined value.



function ValidateData() {
var CanSubmit = false;

// this is the part I'am have trouble with

if (document.forms[0].elements.SubmitBut.value=='Cancel') {
return true;
}

//----------------------------

CanSubmit = ForceEntry(document.forms[0].fFirstName,"Please
supply a first name.");

if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fLastName,"Please supply a last name.");
if (CanSubmit) CanSubmit = ForceEntry(document.forms[0].fTitle,"Please
supply a title.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fPhone1,"Please supply a phone number.");
if (CanSubmit) CanSubmit = isEmail(document.forms[0].fEmail1,"Please
supply valid email address.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fOrgAddress1,"Please supply an office
address.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fOrgCity,"Please supply an office city.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fOrgState,"Please supply an office state.");
if (CanSubmit) CanSubmit =
isZipCode(document.forms[0].fOrgZipCode,"Please supply an office zip
code.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fOrgCountry,"Please supply your office
country.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fPassword,"Please supply a password.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fPassword2,"Please supply retype password.");
if (CanSubmit) CanSubmit =
CheckPassword(document.forms[0].fPassword,document.forms[0].fPassword2,"Plea
se check or retype password.");
return CanSubmit;
}

Martin Honnen said:
this is what I have in my funtion, but returns undefind value?

if (document.forms[0].submit.value=="Cancel") {
return true;
}

Give the button a name
<input type="submit" name="submitButton"
then you can read
document.forms[0].elements.submitButton.value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top