I want to validate this Form. I need each and every checkbox to be filled.
anybody can help?
<html>
<head>
<title>Title</title>
</head>
<body>
<form name="the_form" method="post" action="">
<table>
<tr><td><input type="submit" value="Create Record" /></td></tr>
<tr><td> </td></tr>
<tr>
<td>Text box 1</td>
<td><input type="text" value="1" name="textbox[1]" /></td>
</tr>
<tr>
<td>Text box 2</td>
<td><input type="text" value="2" name="textbox[2]" /></td>
</tr>
<tr>
<td>Text box 3</td>
<td><input type="text" value="3" name="textbox[3]" /></td>
</tr>
...
...
...
...
<tr>
<td>Text box N</td>
<td><input type="text" value="N" name="textbox[N]" /></td>
</tr>
</table>
</form>
</body>
</html>
Thanks.
Jen
Textbox Array Validation
Moderator: General Moderators
Something like:
Code: Select all
function validatethis()
{
var theFormElems = document.forms.the_form.getElementsByTagName('input');
for (var i = 0; i < theFormElems.length; i++)
{
if (theFormElemsїi].type == "checkbox" && theFormElemsїi].checked != "true")
{
alert("BAD KITTY!");
return false;
}
}
}I am Sorry
Its not checkboxes.. TEXTBOXES.
-
ilovetoast
- Forum Contributor
- Posts: 142
- Joined: Thu Jan 15, 2004 7:34 pm
Use the base validation scripts I posted previously here.
For each textbox in the form 1, 2, 3, ... N add a validation definition according to the following structure:
peace
For each textbox in the form 1, 2, 3, ... N add a validation definition according to the following structure:
Code: Select all
var validation_definitions=
ї
ї// submit button (not always first - just first in this form)
ї
// No validation on submit button.
]
],
ї// textboxї1]
ї
її"req"], "ERROR: You forgot item 1."]
]
],
ї// textboxї2]
ї
її"req"], "ERROR: You forgot item 2."]
]
],
ї// textboxї3]
ї
її"req"], "ERROR: You forgot item 3."]
]
],
....
ї// textboxїN]
ї
її"req"], "ERROR: You forgot item N."]
]
]
];