else if validation help 
Author Message
 else if validation help

Hi Group,
I need help with the following script.  I have 2 text boxes and 1
dynamically filled list box.  There is one search button.  I want to prevent
the users from specifying more than one search criteria.  The code I've been
playing with is something on the order of:
function validateSearch()
If (form1.txtID.value != "") && ((form1.txtPositon.value != "") ||
(form1.txtDate.value != ""))
Quote:
}else{

If (form1.txtPosition.value != "") && ((form1.txtID.value != "") ||
(form1.txtDate.value != ""))
Quote:
}else{

If (form1.txtDate.value != "") && ((form1.txtPositon.value != "") ||
(form1.txtID.value != ""))
 alert("Please use only one search criteria!");

Any help?  I'm getting brain frazzled!
--
Donna

* If you can't be a good example, then you'll just have to be a
  horrible warning. - Catherine Aird-



Thu, 26 Aug 2004 10:49:44 GMT  
 else if validation help

| The code I've been playing with is something on the order of:

I'm not sure if your ORIGINAL code has the same problem, but the brackets
didn't match. You were

Anyway, here's what I would suggest instead:

var
id = form1.txtID.value,
ps = form1.txtPosition.value,
dt = form1.txtDate.value,
arguments = // this will count the number of nonempty fields
(id == "" ? 0 : 1) +
(ps == "" ? 0 : 1) +
(dt == "" ? 0 : 1);

if (arguments == 1) return true; // submit form
else {
alert(arguments==0?
"You'll need to use a search criteria.":
"Please use only one search criteria!");
return false; // don't submit form

Quote:
};

:: "Ekevu Guepardo" ::
:: Acinonyx jubatus ::
:: Porto Alegre, BR ::


Thu, 26 Aug 2004 11:48:53 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Client-side Radio Button Validation-Help?

2. Date validation script needed - Please help!!!

3. validation help needed!

4. Help needed with form validation

5. Help!Validation error.

6. Help to correct VBScript/JavaScript form validation...

7. Please HELP : data validation problem !!!

8. Date validation script needed - Please help!!!

9. Pathname validation - need your help testing this

10. Validation of fileds Please Help I am new.

11. Help Needed Debugging Code - Form Validation

12. help with this javascript field validation

 

 
Powered by phpBB® Forum Software