berkshirea
Technical User
hi guys,
i've been trying to solve this but no joy so far. the code is below.
the first textfield is required and is working. the 2 checkboxes are not required but when the user checks them the textfield opposite them becomes a required field.
would you give some suggestions please.
thanks
i've been trying to solve this but no joy so far. the code is below.
the first textfield is required and is working. the 2 checkboxes are not required but when the user checks them the textfield opposite them becomes a required field.
would you give some suggestions please.
thanks
Code:
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript"><!--
function VF_form1(){ //v2.5
<!--start_of_saved_settings-->
<!--type,text,name,textfield,required,true,errMsg,txtfiled1-->
<!--end_of_saved_settings-->
var theForm = document.forms['form1'];
var errMsg = "";
var setfocus = "";
var fName = document.getElementById('textfield2').value;
var chkBox = document.getElementById('checkbox');
var isDataValid = true;
if (theForm['textfield'].value == ""){
errMsg = "txtfiled1";
setfocus = "['textfield']";
}
if (errMsg != ""){
alert(errMsg);
eval("theForm" + setfocus + ".focus()");
}
else theForm.submit();
}//-->
</script>
</head>
<body>
<form action="" method="post" name="form1" id="form1" onsubmit="VF_form1();return false;">
<label>
<input type="text" name="textfield" />
</label>
<p>
<input type="checkbox" name="checkbox" value="checkbox" />
<label>
<input type="text" name="textfield2" />
</label>
</p>
<p>
<input type="checkbox" name="checkbox2" value="checkbox" />
<input type="text" name="textfield3" />
</p>
<p>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</p>
</form>
</body>
</html>