General discussion

Locked

Form validation

By christine ·
I have a form that currently has Dreamweaver validation on the text fields. But now I want to validat additional drop down boxes in the same field. I have tried using code such as:

<script language="JavaScript">
function validate() {
if(document.form1.CardType.value != "*") returnVal = true;
else {
returnVal = false;
alert("Please select a Card Type");
}

if(document.form1.ExpMonth.value != "*") returnVal = true;
else {
returnVal = false;
alert("Please select a Expiration Month");
}

if(document.form1.ExpYear.value != "*") returnVal = true;
else {
returnVal = false;
alert("Please select a Expiration Year");
}

}
</script>

Does anyone have any suggestions???

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

I think I know...

by lukepronker In reply to Form validation

Looking at your JavaScript, your "if" conditionals read "if the value of the input 'CardType' does not equal '*', then returnVal = true." I think you just put your thoughts down wrong. I think what you are trying to say is "if there is no value in'CardType', THEN perform these functions."
The JavaScript for that would be:
if(!document.form1.CardType.value) {
function .....
doing(stuff);
}

I dont know if that's what you were trying to do... but if you want, I made a contact form that uses a bunch of JavaScript to validate it before you send it... it's at : http://www.geocities.com/superbhome
then click on "contact" on the side bar.

Back to Web Development Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums