List Info

Thread: Re: Form Validation




Re: Form Validation
country flaguser name
United States
2007-09-21 06:16:04

Sorry, forgot ...

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&gt; return validateForm(this)
>
>; not this.form
>
&gt; 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
>
&gt;
>&gt; 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
&gt;> form.. actually just one field as a start but its not even
>;> working..here is the code
>;>
>;> <html&gt;
>&gt; <head&gt;
>&gt; <script language=&quot;javascript">
>>
>> function validateForm(myform)
>> {
>&gt; var valid = false
&gt;> if(myform.pw.value != null)
&gt;> {
>&gt; valid = true
>;> }
>&gt; return valid
&gt;> }
>&gt;
>&gt; </script>
>;> </head&gt;
>&gt; <body&gt;
>&gt; <form action=&quot;myschoolOwnerRegister.jsp&quot; onsubmit=&quot;return
>> validateForm(this.form);">
>>
>> <b>Name : </b>
>> <input type=";text" name=";fname"; value=&quot;FirstName"> <input type=";text"
>>; name=";lname"; value=&quot;lastName&quot;> <br><br>
>>
>> <b> email Address<;/b>
&gt;>
&gt;> <input type=";text" name=";email";> <br><br>
>>
>> <b>user name : </b> <input type=";text" name=";userName&quot;>&lt;br><;br>
&gt;>
&gt;> <b>password :</b>; <input type=";password&quot; name=";pw"&gt; <br> <br>
>>
>> <input type=";submit&quot; value=&quot;Register&quot;>
>>
>> </form&gt;
>&gt; </body&gt;
>&gt; </html&gt;
>&gt;
>&gt;
>&gt; it still forwards me to the next page even though the pw field is
>&gt; null... and when i changed the validateForm function to simply
&gt;>
&gt;> function validateForm(myform)
>> {
>&gt; return false
&gt;> }
>&gt;
>&gt; it worked.. so i guess the problem is with my if statement.. i tried
&gt;> it on different fields and different conditions yet it still seems to
>&gt; be returning true...
>>
>> can some one please help me? it's driving me crazy!
&gt;>
&gt;>
&gt;>
&gt;> Visit http://aiaiai.com for more groups to join Yahoo! Groups Links
&gt;>
&gt;>
&gt;>

__._,_.___
Recent Activity
Visit Your Group
New web site?

Drive traffic now.

Get your business

on Yahoo! search.

Beauty Groups

on Yahoo! Groups

A great place to

connect and share.

Find Enlightenment

Yoga groups and

resources on

Yahoo! Groups.

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )