It would also be an added bonus if I can get some tips on setting requirements to email format (ie blank@blank.com) and numerical format for phone numbers (ie 444-555-6666).

Thanks again,

I would recommend using javascript for any input validation but if you insist on using php you would have to do some research on php regular expressions vs. your personal requirements.

Let me know how you go, Regards X

Following fragement of web page helps to understand the basics of validation.

Read more on Regular Expression.

<html>
<head>
  <title>Example 1</title>
  <style type="text/css">
    .formTitle {vertical-align:top; text-align:right;}
  </style>

<script type="text/JavaScript">

  function validate(form) {
    var returnValue = true

    var name=form.txtName.value
    if (name=="")
      {
        returnValue = false;
        alert("You must enter a name")
        document.frmCompetition.txtName.focus();
      }

    var email=form.txtEmail.value
    var rxEmail = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-z]{2,6}(\.[a-z]{2})?$/i;

    if (!rxEmail.test(email))
      {
        returnValue = false;
        alert("You must enter a valid email address")
        document.frmCompetition.txtEmail.focus()
      }

    var radioChosen = false;
    var radioButtons = form.radAnswer;
    for (var i=0; i<radioButtons.length; i++) {
    if (radioButtons[i].checked)
      {
      radioChosen=true;
      }
    }

    if (radioChosen == false) {
      returnValue = false;
      alert("You did not answer the question");
    }

    var tieBreaker=form.txtTieBreaker.value
    var tieBreakerWords = tieBreaker.split(/\s+/g);
    wordCount = tieBreakerWords.length;

    if (tieBreaker=="")
      {
        returnValue = false;
        alert("You must enter an answer for the tie breaker")
        document.frmCompetition.txtTieBreaker.focus();
      }

    if (wordCount > 20) {
      returnValue = false;
      alert("Your tie breaker answer must be no more than 20 words. You entered "+ wordCount+ "words.");
      document.frmCompetition.txtTieBreaker.focus();
    }
    return returnValue
  }    

  </script>

</head>
<body>

<form name="frmCompetition" action="competition.php" method="post" onsubmit="return validate(this);">
<table>
  <tr>
    <td class="formTitle">Name: </td>
    <td><input type="text" name="txtName" size="18" /></td>
  </tr>
  <tr>
    <td class="formTitle">Email: </td>
    <td><input type="text" name="txtEmail" size="18" /></td>
  </tr>
  <tr>
    <td class="formTitle">Answer: </td>
    <td><input type="radio" name="radAnswer" value="Red" /> Red<br />
          <input type="radio" name="radAnswer" value="Gray" /> Gray<br />
          <input type="radio" name="radAnswer" value="Blue" /> Blue
    </td>
  </tr>
  <tr>
    <td class="formTitle">Tie breaker <br/ ><small>(no more than 20 words)</small>: </td>
    <td><textarea name="txtTieBreaker" cols="30" rows="3" /></textarea></td>
  </tr>
  <tr>
    <td class="formTitle"></td>
    <td><input type="submit" value="Enter now"  /></td>
  </tr>
</table>

</form>

</body>
</head>
</html>

hi
i just view your code but i just give a one way for validation all this
like mail,web,no. etc u should use spry frame work of java script
this you can download after searching from google ok.
which include the file .js and .css for diffrent element like textbox,textarea,listbox,checkbox etc.

this use you can after some syntax which you can learn from the given help in this frame work

I hope this can helping to you.
Thanks

This article has been dead for over six months. Start a new discussion instead.