PDA

View Full Version : field required validation


petertran123
09-13-2002, 06:03 PM
how to validate the field
I previous posted, but i can't get a straight answer. Please Help.....

i create 2 forms:

form 1: with has PrimarySSN and SecondarySSN after user fill in and click submit and process to the second page which is

form 2: on form 2 will display previous information which is PrimarySSN and SecondarySSN.

on form 2 there are more fields need to fill in, example name and address.

form here i wanted to validate the SecondarySSN, the form will check if SecondarySSN has pass parameter to the form then require the user to fill in First name and Last Name. On otherhands, If SecondarySSN field parameter did not pass from form1 then the field empty. If the secondaySSN field is empty then do not need to process or require to fill out First name and Last Name. the SecondarySSN is padding and let the form submit without it..

Please help me as your wiset

Peter

:confused:

beetle
09-13-2002, 07:18 PM
Well, see the 'fValidate' link in my signature? Click it. My script validates Social Security Numbers.

2nd, visit this post (http://www.codingforums.com/showthread.php?s=&threadid=4555) and read through it.

If after doing both of these, you are still stuck, let me know.

Cheers :D

petertran123
09-13-2002, 07:46 PM
this is a picture how i wanted.

PrimaryFirstName(required)
PrimaryLastName(Required)
PrimarySSN(required)


and now come to the second part of Secondary:


SecondaryLastName*
SecondaryFirstName*
SecondarySSN

* Required only if SecondarySSN not blank

Now, i need a script to validate if SecondarySSN not blank then users are required to enter SecondaryLastName and SecondaryFirstName. Otherwise, if SecondarySSN is blank then users are not required to enter SecondaryFirstName and SecondaryLastName.

I'm waitng for your help.
Thanks

umm
09-13-2002, 09:19 PM
this will get you started. It is by no means a comprehensive validation. You should also follow beetle's suggestions.



<script language="javascript" type="text/javascript">
<!--
function validate(form){

if(form.s_ssn.value!=""){
if(form.s_lastName.value==""){
alert("If you filled out the Secondary SSN then please enter your LAST name")
form.s_lastName.focus()
return false
} else
if(form.s_firstName.value==""){
alert("If you filled out the Secondary SSN then please enter your FIRST name")
form.s_firstName.focus()
return false
}
}
return true
}
//-->
</script>




...the form for this script...




<form action="javascript: alert('Success')" method="post" onsubmit="return validate(this)">
<input type="text" name="s_ssn">S_SSN
<br>
<input type="text" name="s_lastName">S_Last Name
<br>
<input type="text" name="s_firstName">S_First Name
<br>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>

petertran123
09-16-2002, 06:14 PM
Umm,

thanks for your help..i will have a problem using your code..the field is required when someone's entering Secondary SSN. If they are not entered anything in. I wanted the field will not be required and padding..Please help

umm
09-16-2002, 10:51 PM
Originally posted by petertran123
Umm,

thanks for your help..i will have a problem using your code..the field is required when someone's entering Secondary SSN. If they are not entered anything in. I wanted the field will not be required and padding..Please help
Which field do you mean?