»
EnglishFrenchVietnamese

Print - Radio Question Validator - JavaScriptBank.com

Full version: jsB@nk » Form » Validation » Radio Question Validator
URL: http://www.javascriptbank.com/radio-question-validator.html

Radio Question Validator © JavaScriptBank.comValidates that every Radio Button question on the form has been answered. No modifications needed!

Full version: jsB@nk » Form » Validation » Radio Question Validator
URL: http://www.javascriptbank.com/radio-question-validator.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">// David Blackledge , http://david.blackledge.com/<!--  Beginvar menu_selection="";var radio_selection="";function  checkForm() {if (dropDownMenu() && radioButtons()) {document.forms[0].results1.value=menu_selection;document.forms[0].results2.value=radio_selection;alert("\nForm has been filled out correctly.");   }}function dropDownMenu(form)  {var myindex=document.forms[0].menu.selectedIndex;if (myindex==0) {alert("\nYou must make a selection from the drop-down menu.");document.forms[0].menu.focus();}else {menu_selection=document.forms[0].menu.options[myindex].value;return true;   }}function radioButtons() {if (radio_selection=="")alert("\nYou must check one of the radio buttons.");else {return true;   }}function resetForm() {document.forms[0].menu.options[0].selected = true;menu_selection="";radio_selection="";}function about() {alert("\nVALIDATOR checks to see that a selection has been made from  the drop-down menu and that a radio button has been checked.\n\nIf filled out properly, the data will be displayed below.");}// End --></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<FORM><TABLE BORDER=4  WIDTH=500><TR><TD align="center"><FONT SIZE=+1><B>MENU</B></FONT><TD align="center"><FONT SIZE=+1><B>RADIOS</B></FONT></TR><TR><TD align="center"><SELECT NAME="menu" SIZE=1><OPTION SELECTED VALUE=""> --- How many times have you been to TJS? ---<OPTION VALUE="one">Once<OPTION VALUE="two">Twice<OPTION VALUE="three">Three times<OPTION VALUE="four">Four times<OPTION VALUE="five">Five times<OPTION VALUE="six">Six times<OPTION VALUE="seven">Seven times<OPTION VALUE="eight">Eight times<OPTION VALUE="nine">Nine times<OPTION VALUE="ten">Ten+ times</SELECT><TD align="center"><BR>Will you be back to TJS?<br><INPUT TYPE="radio" NAME="radiobutton" onClick="radio_selection='yes'">YES<INPUT TYPE="radio" NAME="radiobutton" onClick="radio_selection='no'">NO<INPUT TYPE="radio" NAME="radiobutton" onClick="radio_selection='maybe'">MAYBE</TR></TABLE><BR><TABLE BORDER=0 WIDTH=400><TD align="center"><INPUT TYPE="reset"   VALUE="Reset" onClick="resetForm()"><TD align="center"><INPUT TYPE="button" VALUE="Check Form Fields" onClick="checkForm()"><TD align="center"><INPUT TYPE="button" VALUE="About" onClick="about()"></TABLE><BR><TABLE BORDER=4 WIDTH=250><TR><TD align="center">MENU: <TD align="center">RADIO:</TR><TR><TD align="center"><INPUT  TYPE="text"  NAME="results1" SIZE=7><TD align="center"><INPUT  TYPE="text"  NAME="results2" SIZE=7></TR></TABLE><BR></FORM><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->