brownbrod Posted February 13, 2014 Share Posted February 13, 2014 Hi. Just a quick question. If you browse the web, I see that there are several form validations out there but they required JAVASCRIPT. I have serveral forms with CHECKBOX for survey questions. Several of the questions only allow you to pick one box. This is my form for one of the questions: <form method="post" action="hasq3.php"> <table border="0" width="100%"> <tr> <td width="2%" height="30"> <input type="checkbox" name="q2" value="Quality Plan Does Not Exist" tabindex="1"></td> <td width="103%" height="30">Quality Plan Does Not Exist</td> </tr> <tr> <td width="2%" height="30"> <input type="checkbox" name="q2" value="Draft Quality Plan Exists" tabindex="2"></td> <td width="103%" height="30">Draft Quality Plan Exists</td> </tr> <tr> <td width="2%" height="30"> <input type="checkbox" name="q2" value="Draft Quality Plan Following HW Quality Plan Template" tabindex="3"></td> <td width="103%" height="30">Draft Quality Plan Following HW Quality Plan Template</td> </tr> </tr> <td width="71%"> <button type="submit">Next Page</button> </form> Is there a way to instruct the PHP to only select one checkbox? On another form I have an input box for "NAME". Is there a way to say that this field is required? If I use JAVA do I have to save the file as a .jsp file or can this be imbedded in the <Head></HEAD>. I am not familiar with JAVA. I greatly appreciate any help you can provide. Thanks, Quote Link to comment Share on other sites More sharing options...
ginerjm Posted February 13, 2014 Share Posted February 13, 2014 Generally one uses an input type of radio buttons when their is to be only one allowed response. Checkboxes are for multiple responses or for separate and distinct ones. Quote Link to comment Share on other sites More sharing options...
rythemton Posted February 14, 2014 Share Posted February 14, 2014 I second ginerjm, if only one selection is allowed, you want a radio button or drop-down list. Also, you should use JavaScript for validation. Using PHP means that the person has to submit the form before they know that what they submit was invalid, unless you use Ajax (which uses JavaScript) which is going to require more work than just using JavaScript in the first place. Your PHP should also validate the information in case the user has JavaScript disabled, but you shouldn't make people wait to know they've input invalid information if at all possible. You don't need to use Java. Java is not JavaScript. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.