how to validate gender by using radio button in java script
when submitting form even if we not selecting gender its not showing alert.how 2 write code to get proper results
Status:
Open Aug 05, 2010 - 12:20 AM
forms, code, Button, java, script
2answers
Answers
Aug 09, 2010 - 01:46 AM
Hi Kalaivani0705The first step is to create the radio buttons 1st
2nd
The next step is to validate using the java script.function valbutton(thisform) {// place any other field validations that you require here// validate myradiobuttonsmyOption = -1;for (i=thisform.myradiobutton.length-1; i > -1; i--) {if (thisform.myradiobutton[i].checked) {myOption = i; i = -1;}}if (myOption == -1) {alert("You must select a radio button");return false;}alert("Gender : " + thisform.myradiobutton[myOption].value);// place any other field validations that you require herethisform.submit(); // this line submits the form after validation}Hope this helps
Mar 31, 2012 - 10:56 AM
The question looks to be abandoned by the user who asked it. If no action is taken within 2 days, a Quomon Moderator will consider closing the question and distributing the points.
The Quomon Team
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment