I am trying to use the following java script to validate information inside a <fieldset>
Here is the javascript code:
<code>
<script language="JavaScript">
function check_form(form)
{
return_boolean = true;
obj = eval(form);
for(i=0;i<obj.length;i++)
{
alert(obj.length);
field_name = obj.myForm.name.element.name;
alert(field_name);
if (field_name.indexOf("_ck" != -1)
{
if (obj.element.value == ""
{
obj.element.style.backgroundColor = "red";
return_boolean = false
}
else
{
obj.element.style.backgroundColor = "white";
}
}
}
return return_boolean;
}
</script>
Here is my simple example I am trying to get to work:
<form name="myForm" onsubmit="return check_form(this)">
<fieldset style="border:1 solid blue; width:250px;height:100px;">
<legend align="left"> CONTACT INFORMATION</legend><BR>
<label for="firstname">First Name</label><input type="text" id="firstname_ck">
</SELECT>
</fieldset>
<input type=submit value="Submit">
</form>
</code>
Thanks for any help,
Here is the javascript code:
<code>
<script language="JavaScript">
function check_form(form)
{
return_boolean = true;
obj = eval(form);
for(i=0;i<obj.length;i++)
{
alert(obj.length);
field_name = obj.myForm.name.element.name;
alert(field_name);
if (field_name.indexOf("_ck" != -1)
{
if (obj.element.value == ""
{
obj.element.style.backgroundColor = "red";
return_boolean = false
}
else
{
obj.element.style.backgroundColor = "white";
}
}
}
return return_boolean;
}
</script>
Here is my simple example I am trying to get to work:
<form name="myForm" onsubmit="return check_form(this)">
<fieldset style="border:1 solid blue; width:250px;height:100px;">
<legend align="left"> CONTACT INFORMATION</legend><BR>
<label for="firstname">First Name</label><input type="text" id="firstname_ck">
</SELECT>
</fieldset>
<input type=submit value="Submit">
</form>
</code>
Thanks for any help,