List Info

Thread: How to do Validation for the whole Form at one time?




How to do Validation for the whole Form at one time?
country flaguser name
India
1969-12-31 18:00:00

Hi,

I am creating a form with 30 fields, I need to do validation that cells should not be empty before submitting. For each cell I have to give condition saying


document.formname.fieldname.value== "" alert(some message)

is there any ways to just give it in one statement ........ I tried this

document.getAllElementByID("formname")=="" ......... but this does not work.

If anyone has any idea about this, please assist.

Thanks & Regards,
Sunitha.



---------------------------------
Here’s a new way to find what you're looking for - Yahoo! Answers

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Re: How to do Validation for the whole Form at one time?
country flaguser name
United States
1969-12-31 18:00:00

Hello,

Watch for the text in red to better understand.

The function will work with as many fields as your form might have.

Regards, ;)

http://www.madros.com

<;html>
<head&gt;
<script>
function validateForm(form)
{
var x = form.elements;

for (var i=0;i<x.length-1;i++)
{
if (!x[i].value) {
alert(x[i].id + " is empty.&quot;);
}
}
}
&lt;/script&gt;
</head>
&lt;body>
<form name=";myForm&quot;>
&lt;table>;
<tr&gt;<td&gt;Name:<;/td><;td><;input id="Name" name=";name"></td></tr>
<;tr><td>Last Name:</td><td><input id="Last Name" name=";lastname&quot;>&lt;/td>&lt;/tr>
<tr><td>E-mail:</td><td><input id="E-mail" name=";email";></td></tr>
&lt;tr><;td>Subject:</td><td><input id="Subject"; name=";subject&quot;><;/td><;/tr>
<tr>&lt;td>Message:</td><td><textarea id="Message"; name=";message&quot;><;/textarea&gt;</td></tr>
<tr><td>&nbsp;</td><td><input type=";submit&quot; onclick=&quot;validateForm(this.form);&quot;></td></tr>
</table&gt;
</form>
</body&gt;
</html>

-+-+-+-+-+-+-+-+-

sunitha semval < ss_semval%40yahoo.co.in">ss_semvalyahoo.co.in> wrote: Hi,

I am creating a form with 30 fields, I need to do validation that cells should not be empty before submitting. For each cell I have to give condition saying


document.formname.fieldname.value== "&quot; alert(some message)

is there any ways to just give it in one statement ........ I tried this

document.getAllElementByID(&quot;formname")==&quot;" ......... but this does not work.

If anyone has any idea about this, please assist.

Thanks & Regards,
Sunitha.



---------------------------------
Here’s a new way to find what you're looking for - Yahoo! Answers

[Non-text portions of this message have been removed]





---------------------------------
Sucker-punch spam with award-winning protection.
Try the free Yahoo! Mail Beta.

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1-2]

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