Field Validation conditional to a radio button selection.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to force a Textarea entry in FrontPage if a user selects a
specific radio button. I am building an online survey where in one of the
questions, if a user selects "No", I want it mandatory that a reason be
entered.
 
Hi Mark,

Yes it is.

<head>

<meta name="GENERATOR" content="Microsoft FrontPage 6.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<title>New Page 3</title>

<script type="text/javascript" language="javascript">

function checkAnswer(theForm) {

debugger;

if (theForm.yesno[1].checked) {

if (theForm.Response.value.length > 0 ) {

return true;

} else {

alert("Please enter a reason.");

return false;

}

}

return true;

}

</script>

</head>

<body>

<form name="form1">

<input type="radio" checked name="yesno" > Yes

<input type="radio" name="yesno" onclick="this.form.Response.disabled=false; this.form.Response.focus(); alert('Please enter the
reason.'); " > No

<textarea name="Response" disabled >

</textarea>

<input type="submit" onclick="checkAnswer(this.form);" >

</form>

</body>

</html>
 
Oops, I forgot to remove the debugger statement. Please remove it.

Your welcome.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 102 Components For FP
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible


Mark R. said:
Thanks! I'll give that a try!

MD Websunlimited said:
Hi Mark,

Yes it is.

<head>

<meta name="GENERATOR" content="Microsoft FrontPage 6.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<title>New Page 3</title>

<script type="text/javascript" language="javascript">

function checkAnswer(theForm) {

debugger;

if (theForm.yesno[1].checked) {

if (theForm.Response.value.length > 0 ) {

return true;

} else {

alert("Please enter a reason.");

return false;

}

}

return true;

}

</script>

</head>

<body>

<form name="form1">

<input type="radio" checked name="yesno" > Yes

<input type="radio" name="yesno" onclick="this.form.Response.disabled=false; this.form.Response.focus(); alert('Please enter the
reason.'); " > No

<textarea name="Response" disabled >
 
Back
Top