Also, the test for empty probably needs to test against "" rather than null.
Regards, Dave S
----- Original Message -----
From: "David Smart" < smartware.consulting%40gmail.com">smartware.consultinggmail.com>
To: < JavaScript_Official%40yahoogroups.com">JavaScript_Officialyahoogroups.com>
Sent: Friday, September 21, 2007 9:12 PM
Subject: Re: [JavaScript] Form Validation
> in the <form> return validateForm(this)
>
> not this.form
>
> Regards, Dave S
>
> ----- Original Message -----
> From: "princesslou_83" < princesslou_83%40yahoo.com">princesslou_83yahoo.com>
> To: < JavaScript_Official%40yahoogroups.com">JavaScript_Officialyahoogroups.com>
> Sent: Thursday, September 20, 2007 6:46 AM
> Subject: [JavaScript] Form Validation
>
>
>> Hi all,
>>
>> I am new to javascript.. and I am trying to use it for form validation
>> but it's giving me a headache.. iam trying to validate a v v simple
>> form.. actually just one field as a start but its not even
>> working..here is the code
>>
>> <html>
>> <head>
>> <script language="javascript">
>>
>> function validateForm(myform)
>> {
>> var valid = false
>> if(myform.pw.value != null)
>> {
>> valid = true
>> }
>> return valid
>> }
>>
>> </script>
>> </head>
>> <body>
>> <form action="myschoolOwnerRegister.jsp" onsubmit="return
>> validateForm(this.form);">
>>
>> <b>Name : </b>
>> <input type="text" name="fname" value="FirstName"> <input type="text"
>> name="lname" value="lastName"> <br><br>
>>
>> <b> email Address</b>
>>
>> <input type="text" name="email"> <br><br>
>>
>> <b>user name : </b> <input type="text" name="userName"><br><br>
>>
>> <b>password :</b> <input type="password" name="pw"> <br> <br>
>>
>> <input type="submit" value="Register">
>>
>> </form>
>> </body>
>> </html>
>>
>>
>> it still forwards me to the next page even though the pw field is
>> null... and when i changed the validateForm function to simply
>>
>> function validateForm(myform)
>> {
>> return false
>> }
>>
>> it worked.. so i guess the problem is with my if statement.. i tried
>> it on different fields and different conditions yet it still seems to
>> be returning true... >> >> can some one please help me? it's driving me crazy!
>>
>>
>>
>> Visit http://aiaiai.com for more groups to join Yahoo! Groups Links
>>
>>
>>