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>
<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.");
}
}
}
</script>
</head>
<body>
<form name="myForm">
<table>
<tr><td>Name:</td><td><input id="Name" name="name"></td></tr>
<tr><td>Last Name:</td><td><input id="Last Name" name="lastname"></td></tr>
<tr><td>E-mail:</td><td><input id="E-mail" name="email"></td></tr>
<tr><td>Subject:</td><td><input id="Subject" name="subject"></td></tr>
<tr><td>Message:</td><td><textarea id="Message" name="message"></textarea></td></tr>
<tr><td> </td><td><input type="submit" onclick="validateForm(this.form);"></td></tr>
</table>
</form>
</body>
</html>
-+-+-+-+-+-+-+-+-
sunitha semval < ss_semval%40yahoo.co.in">ss_semval
yahoo.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== "" 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]
---------------------------------
Sucker-punch spam with award-winning protection.
Try the free Yahoo! Mail Beta.
[Non-text portions of this message have been removed]
.