Advertisement
Guest User

Drop Down List

a guest
Apr 18th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.88 KB | None | 0 0
  1. <form action="html_form_send.php" name="myForm" onsubmit="return(validate());" method="post">
  2. <table cellspacing="2" cellpadding="2" border="1">
  3. <tbody>
  4. <tr>
  5. <td align="right">First Name*</td>
  6. <td><input type="text" name="firstname" /></td>
  7. </tr>
  8. <tr>
  9. <td align="right">Last Name*</td>
  10. <td><input type="text" name="lastname" /></td>
  11. </tr>
  12. <tr>
  13. <td align="right">Email *</td>
  14. <td><input type="text" name="email" /></td>
  15. </tr>
  16. <tr>
  17. <td align="right">Confirm Email *</td>
  18. <td><input type="text" name="confirmation_email" /></td>
  19. </tr>
  20. <tr>
  21. <td align="right">Role *</td>
  22. <td>
  23. <select name="role">
  24. <option value="">--Select your role--</option>
  25. <option value="student">Student</option>
  26. <option value="professor">Professor</option>
  27. <option value="media professional">Media Professional</option>
  28. <option value="other">Other</option>
  29. </select>
  30. </td>
  31. </tr>
  32. <tr>
  33. <td align="right">Comment *</td>
  34. <td><textarea name="Comment" cols="25" rows="6"></textarea></td>
  35. </tr>
  36. <tr>
  37. <td align="right"></td>
  38. <td><input type="submit" value="Submit" /></td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. </form>
  43. <script type="text/javascript">// <![CDATA[
  44. function validateEmail()
  45. {
  46.  
  47.  var emailID = document.myForm.email.value;
  48.  atpos = emailID.indexOf("@");
  49.  dotpos = emailID.lastIndexOf(".");
  50.  if (atpos < 1 || ( dotpos - atpos < 2 ))
  51.  {
  52.      alert("Please enter correct email address")
  53.      document.myForm.email.focus() ;
  54.      return false;
  55.  }
  56.  return( true );
  57. }
  58. // ]]></script>
  59. <script type="text/javascript">// <![CDATA[
  60. // Form validation code will come here.
  61.  
  62. function validate()
  63. {
  64.  
  65.  if( document.myForm.firstname.value == "" )
  66.  {
  67.    alert( "Please provide your first name!" );
  68.    document.myForm.firstname.focus() ;
  69.    return false;
  70.  }
  71.  
  72.  if( document.myForm.lastname.value == "" )
  73.  {
  74.    alert( "Please provide your last name!" );
  75.    document.myForm.lastname.focus() ;
  76.    return false;
  77.  }
  78.  
  79.  if( document.myForm.email.value == "" )
  80.  {
  81.    alert( "Please provide your Email!" );
  82.    document.myForm.email.focus() ;
  83.    return false;
  84.  }else{
  85.    var ret = validateEmail();
  86.    if( ret == false )
  87.    {
  88.       return false;
  89.    }
  90.  }
  91.  
  92.  if( document.myForm.confirmation_email.value == "" )
  93.  {
  94.    alert( "Please provide your Email!" );
  95.    document.myForm.confirmation_email.focus() ;
  96.    return false;
  97.  }else if (document.myForm.email.value != document.myForm.confirmation_email.value){
  98.    alert( "Please enter the same email address!" );
  99.    document.myForm.confirmation_email.focus() ;
  100.    return false;
  101.  }
  102.  
  103.  if( document.myForm.role.value == "" )
  104.  {
  105.    alert( "Please provide your role!" );
  106.    document.myForm.role.focus() ;
  107.    return false;
  108.  }
  109.  if( document.myForm.Comment.value == "" )
  110.  {
  111.    alert( "Please provide your Comment!" );
  112.    document.myForm.Comment.focus() ;
  113.    return false;
  114.  }
  115.  return( true );
  116. }
  117. // ]]></script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement