Guest User

Untitled

a guest
Jul 17th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <html>
  2.  
  3. <head> <title> Customer Login Form </title></head>
  4.  
  5. <script>
  6.  
  7. function myFunction()
  8. {
  9. var x =document.forms["myForm"]["customerName"].value;
  10. var y = document.forms["myForm"]["customerPassword"].value;
  11.  
  12.  
  13.  
  14. //Name
  15.  
  16. if(!(x.search(/[^a-zA-Z0-9]+/) === -1))
  17. {
  18. alert("Invalid Customer Name");
  19. return false;
  20. }
  21.  
  22. if(x==null || x.length > 15 || x==" ")
  23. {
  24. alert("Invalid User Name");
  25. return false;
  26. }
  27. if(y.length < 6 )
  28. {
  29. alert("Invalid Password Length");
  30. return false;
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37. //E-Mail
  38. var e = document.forms["myForm"]["myEmail"].value;
  39. var t = new RegExp("^[a-zA-Z0-9_+&*-]+(?:\\." + "[a-zA-Z0-9_+&*-]+)*@" + "(?:[a-zA-Z0-9-]+\\.)+[a-z" + "A-Z]{2,7}$");
  40. if (t.test(e))
  41. {
  42. return true;
  43. }
  44. else
  45. {
  46. alert("Invalid Email Address");
  47. }
  48.  
  49.  
  50.  
  51.  
  52. //Pincode
  53. var p = document.forms["myForm"]["Pincode"].value;
  54. var q = p.toString();
  55. if(q.length != 6)
  56. {
  57. prompt("Invalid Pincode");
  58. return false;
  59. }
  60.  
  61. }
  62.  
  63.  
  64.  
  65.  
  66. </script>
  67.  
  68. <body>
  69. <form name="myForm" action="first.htm" method="GET" onSubmit="return myFunction();">
  70. <br>
  71. Customer Name: <input type="text" name="customerName" placeholder="User Name ID"/>
  72. <br><br>
  73.  
  74. Email: <input type="text" name="myEmail" placeholder="Email"/>
  75. <br><br>
  76.  
  77. Pincode: <input type="number" name="Pincode">
  78. <br><br>
  79. Password: &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;<input type="password" name="customerPassword" placeholder="Password"/>
  80. <br><br>
  81. <input type="submit" value="submit" />
  82.  
  83.  
  84. </form>
  85. </body>
  86. </html>
Add Comment
Please, Sign In to add comment