|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
One field validates the other
Morning,
I can't get the syntax just right. What I need it to do is say if one field is NOT NULL/Blank then make sure the other field is filled in. This is what I have: <script language="javascript"> if (!(formname.InternetAccess.value == "" && formname.VPEmail.value == "")) { alert("Please enter your VP's email address."); return false; } return (true); } </script> Any thoughts would be greatly appreciated Thanks Laura |
|
#2
|
|||
|
|||
|
RE: One field validates the other
try this
if ((formname.InternetAccess.value != "") && (formname.VPEmail.value == "")) |
|
#3
|
|||
|
|||
|
RE: One field validates the other
Hmmmm.
Still doesn't check. This is the whole thing: <script language="javascript"> function Form_Validator(testform) { if ((testform.InternetAccess.value != "") && (testform.VPEmail.value == "")) { alert("Please enter your VP's email address."); return false; } return (true); } </script> <form name="testform" method="post" onSubmit="return Form_Validator(this)"> |
|
#4
|
|||
|
|||
|
RE: One field validates the other
I just tested it and it worked fine. what does the rest of your form look like. I made my own to match because you did not include the code for yours.
|
|
#5
|
|||
|
|||
|
RE: One field validates the other
This is the form part:
<form name="testform" method="post" onSubmit="return Form_Validator(this)"> <p><font face="Arial, Helvetica, sans-serif">VP email address: <input name="VPEmail" type="text"> </font></p> <p><font face="Arial, Helvetica, sans-serif">Internet Access: <select name="InternetAccess" size="1"> <option selected> </option> <option>Internet Access</option> <option>Internet Access Enhanced</option> <option>Intellitrader</option> </select> <input type="submit" name="Submit" value="Submit"> </font> </form></p> |
|
#6
|
|||
|
|||
|
RE: One field validates the other
The problem is that your select box options do not have any values set. So either you need to add values to the options...
<option value="IA">Internet Access</option> or if you dont want to do that, you can use the selectedIndex property of the select box to determine if a selection has been made... if ((testform.InternetAccess.selectedIndex != 0) && (testform.VPEmail.value == "")) |
|
#7
|
|||
|
|||
|
RE: One field validates the other
Your brilliant
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > One field validates the other |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|