Guest User

Untitled

a guest
Mar 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.88 KB | None | 0 0
  1. <script>
  2. var password= document.forms["PestControl"]["password"].value;
  3. var confirmpassword= document.forms["PestControl"]["confirmpassword"].value;
  4. function validateForm() {
  5. //alert('inside');
  6. var fname = document.forms["PestControl"]["pest_control_name"].value;
  7. var telephone_number = document.forms["PestControl"]["telephone_number"].value;
  8. var email = document.forms["PestControl"]["email"].value;
  9. var address = document.forms["PestControl"]["address"].value;
  10. var description = document.forms["PestControl"]["description"].value;
  11.  
  12.  
  13. var n = telephone_number.length;
  14. //alert(n);
  15. var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
  16. if (fname == "") {
  17. alert("Pest Control Name must be filled out");
  18. document.forms["PestControl"]["pest_control_name"].focus();
  19. return false;
  20. }
  21. else if ((n<10) || (n>10)) {
  22. alert("Enter the 10 Digits Mobile Number(Like : 02225940100)");
  23. document.forms["PestControl"]["telephone_number"].focus();
  24. return false
  25. }
  26. else if(isNaN(telephone_number))
  27. {
  28. alert("Enter the valid Mobile Number(Like : 02225940100)");
  29. document.forms["PestControl"]["telephone_number"].focus();
  30. return false;
  31. }
  32. else if(!validatePhone(telephone_number)) {
  33. document.forms["PestControl"]["telephone_number"].focus();
  34. //$("#name_status").html("Mobile exist, Use different mobile no.");
  35. return false;
  36. }
  37. else if(!filter.test(email)) {
  38. alert("Please Enter Valid Email id");
  39. document.forms["PestControl"]["email"].focus();
  40. return false;
  41. }
  42.  
  43. else if(!validateEmail(email)) {
  44. document.forms["PestControl"]["email"].focus();
  45. return false;
  46. }
  47. else if (address == "") {
  48. alert("Address must be filled out");
  49. return false;
  50. }
  51.  
  52. else if (description == "") {
  53. alert("Description must be filled out");
  54. document.forms["PestControl"]["description"].focus();
  55. return false;
  56. }
  57. else if(!validatePassword()){
  58. alert("password did not matched or blank password fields");
  59. document.forms["PestControl"]["password"].focus();
  60. return false;
  61. }
  62. else if($.trim(password) != $.trim(confirmpassword)){
  63. alert("password did not matched");
  64. document.forms["PestControl"]["password"].focus();
  65. return true;
  66. }
  67.  
  68. else {
  69. document.PestControl.action = "medical_college_process.php?trans=addcollege";
  70. document.PestControl.method = "post";
  71. document.PestControl.submit();
  72. }
  73. }
  74. function validatePassword(){
  75. var password= document.forms["PestControl"]["password"].value;
  76. var confirmpassword= document.forms["PestControl"]["confirmpassword"].value;
  77. var Exist = false;
  78. if((password.value === '') && (confirm_password.value==='')) {
  79. alert();
  80. Exist = false;
  81. }
  82. else if(password.value != confirm_password.value) {
  83. Exist = false;
  84. }
  85. else {
  86. Exist = true;
  87. }
  88. async:false;
  89. return Exist;
  90.  
  91. }
  92. function validateEmail(email){
  93. var Exist = false;
  94. $.ajax({
  95. type:"post",
  96. dataType:"json",
  97. url:"email_validation.php",
  98. data:"email="+email,
  99. success: function(data)
  100. {
  101.  
  102. if(data.success=="0")
  103. {
  104. alert("Email Already Exist With Us..!");
  105.  
  106. Exist = false;
  107. }
  108. else{
  109. Exist = true;
  110. }
  111.  
  112.  
  113.  
  114. },
  115. async:false
  116. });
  117.  
  118. return Exist;
  119. }
  120.  
  121. function validatePhone(phone){
  122. //alert(phone);
  123. var Exist = false;
  124. $.ajax({
  125. type:"post",
  126. dataType:"json",
  127. url:"email_validation.php",
  128. data:"phone="+phone,
  129. success: function(data)
  130. {
  131.  
  132. if(data.success=="0")
  133. {
  134. alert("Number Already Exist With Us..!");
  135. //$("#mobile").focus();
  136. Exist = false;
  137. }
  138. else{
  139. Exist = true;
  140. }
  141.  
  142.  
  143.  
  144. },
  145. async:false
  146. });
  147.  
  148. return Exist;
  149. }
  150. </script>
  151.  
  152. <div class="form-group col-md-12" style="text-align: right;margin-top: 10px;">
  153. <label style="margin-bottom: 0px;">Confirm Password </label>
  154. <input id="confirm_password" type="password" class="form-control" name="confirmpassword" value="">
  155. </div>
  156.  
  157.  
  158.  
  159. <div class="col-md-12" style="text-align: right;margin-top: 10px;">
  160. <button type="button" id="button1" name="" onclick="return validateForm()" class="btn btn-w-m btn-primary">Save</button>
Add Comment
Please, Sign In to add comment