0

How can I set the one of radio button (Identity: HKID, Passport or Chinese ID) must be checked? ONLY one of the Identity ( HKID, Passport or Chinese ID) ) is required before submit.

Thank you very much for your help & support first !

<form method="post" action="ComSec_insert.php" accept-charset="UTF-8">
<br>
<font color="red"><b>Please choose ONE of the Identity : HKID / Passport / Chinese ID  to submit! </b></font>

<br>
<font color="red"><b>ComSec - HKID No.: </b></font><br>
<input type="radio" name="comsec_hkid_tbid" value="<?php echo $row["comsec_hkid_tbid"]; ?>" >
<?php echo $row["comsec_hkid"]; ?>


<br>
<font color="red"><b>ComSec - Passport: </b></font><br>
<input type="radio" name="comsec_passport_tbid" value="<?php echo $row["comsec_passport_tbid"]; ?>" >
<?php echo $row["comsec_passport_country"]." ".$row["comsec_passport_no"]; ?>


<br>
<font color="red"><b>ComSec - Chinese ID: </b></font><br>
<input type="radio" name="comsec_chineseid_tbid" value="<?php echo $row["comsec_chineseid_tbid"]; ?>"  >
<?php echo $row["comsec_chinese_id"]; ?>

<br>
<input type="submit" name="submit" value="Submit"> </form>
Jonas
  • 121,568
  • 97
  • 310
  • 388
Kong Hong
  • 45
  • 1
  • 6

1 Answers1

-1

Well first, put an asterisk next to the question, preferably in red to let the user know that question needs to be filled in order to submit the form.

Then in the php/js (however you want to do it, should do both), you can add simple form validation that checks to make sure the user clicked that button before submitting the form.

For example (Pseudo code)

if(!comsec_hkid_tbid){
   //give them a warning or something. for example
   echo "you did not fill in the question with the asterisk etc
}

**EDIT***** after re-reading the questions a few times, well, keep what i said above lol, but, assuming I'm understanding correctly, if the user is only required to select one option, then dont breakup the form like that, instead use the "SELECT" and "OPTION" of html, and then thereafter, use what i wrote above it.

for example

<select>
   <option> hkid</option>
   <option> passport</option>
   <option> Chinese ID</option>
</select>
somdow
  • 6,268
  • 10
  • 40
  • 58