Guest User

Untitled

a guest
Sep 11th, 2018
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. Verifying if the password field is empty
  2. <form id="form" method="post" action="student.jsp">
  3.  
  4. <label><strong>Username :</strong><br/><br/>
  5. <input type="text" value="" name="username" id="idusername">
  6. </label><br/><br/>
  7.  
  8. <label><strong>Password :</strong><br/><br/>
  9. <input type="text" value="" name="password" id="idpassword">
  10. </label><br/><br/><br/>
  11.  
  12. <input id="minibutton" name="send" type="submit" value="Login" />
  13. </form>
  14.  
  15. $(document).ready(function(){
  16. //global vars
  17. var form = $("#form");
  18. var username= $("#idusername");
  19. var password = $("idpassword");
  20.  
  21. //On Submitting
  22. form.submit(function(){
  23. if(username.val().length==0 || password.val().length==0){
  24. alert('Please enter the username');
  25. return false;
  26. }
  27. else
  28. {
  29. if(password.val().length==0)
  30. {
  31. alert('Please enter the password');
  32. return false;
  33. }
  34.  
  35. else
  36. return true;
  37. }
  38. });
  39. });
  40.  
  41. var password = $("idpassword");
  42.  
  43. var password = $("#idpassword");
  44.  
  45. if(username.val().length==0 || password.val().length==0){
  46. alert('Please enter the username');
  47. return false;
  48. }
  49. else{
  50. if(password.val().length==0)
  51. {
  52. alert('Please enter the password');
  53. return false;
  54. }
  55. else
  56. return true;
  57. }
  58.  
  59. if(username.val().length==0){
  60. alert('Please enter the username');
  61. return false;
  62. }
  63. if(password.val().length==0){
  64. alert('Please enter the password');
  65. return false;
  66. }
  67. return true;
Add Comment
Please, Sign In to add comment