Jump to content

php validation on html form. two choices...


grk101

Recommended Posts

thought i would post in here about this..

 

I have this html

 

    <span style="font-weight:bold">Are you available to coach?* </span>
      
  <label for="areyou">    <input type="radio" name="avcoach" id="avcoach" value="Yes"></label>
      Yes
    
<label for="areyou">     <input type="radio" name="avcoach" id="avcoach" value="No"></label>
      No      </td>
      <td> </td>
    </tr>
  <tr>
    <td colspan="5"><span style="font-weight:bold">If yes,</span>
      
<label for="ifyes">      <input type="radio" name="coachrep" id="coachrep" value="Head Coach/Team Rep"></label>
      Head Coach/Team Rep
<label for="ifyes">      <input type="radio" name="coachrep" id="coachrep" value="Assistant Coach/Team Rep"></label>
      Assistant Coach/Team Rep</td>

 

Currently in my validation in php it makes both fields mandatory.

 

like this

 

if (strlen($avcoach) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please tell us if you can Coach/Rep</font></p>");
}

if (strlen($coachrep) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please tell us if you want to be an Assistance Coach/Rep</font></p>");
}

 

Realistically i wanted to do the following:

 

Do you want to Coach/Rep , Yes then fill out the type of coach/Rep , but if not move on u know?

 

So only make the following mandatory if they select YES from above.

 

<span style="font-weight:bold">If yes,</span>
      
<label for="ifyes">      <input type="radio" name="coachrep" id="coachrep" value="Head Coach/Team Rep"></label>
      Head Coach/Team Rep
<label for="ifyes">      <input type="radio" name="coachrep" id="coachrep" value="Assistant Coach/Team Rep"></label>
      Assistant Coach/Team Rep

 

Link to comment
https://forums.phpfreaks.com/topic/157721-php-validation-on-html-form-two-choices/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.