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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.