Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- var password= document.forms["PestControl"]["password"].value;
- var confirmpassword= document.forms["PestControl"]["confirmpassword"].value;
- function validateForm() {
- //alert('inside');
- var fname = document.forms["PestControl"]["pest_control_name"].value;
- var telephone_number = document.forms["PestControl"]["telephone_number"].value;
- var email = document.forms["PestControl"]["email"].value;
- var address = document.forms["PestControl"]["address"].value;
- var description = document.forms["PestControl"]["description"].value;
- var n = telephone_number.length;
- //alert(n);
- var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
- if (fname == "") {
- alert("Pest Control Name must be filled out");
- document.forms["PestControl"]["pest_control_name"].focus();
- return false;
- }
- else if ((n<10) || (n>10)) {
- alert("Enter the 10 Digits Mobile Number(Like : 02225940100)");
- document.forms["PestControl"]["telephone_number"].focus();
- return false
- }
- else if(isNaN(telephone_number))
- {
- alert("Enter the valid Mobile Number(Like : 02225940100)");
- document.forms["PestControl"]["telephone_number"].focus();
- return false;
- }
- else if(!validatePhone(telephone_number)) {
- document.forms["PestControl"]["telephone_number"].focus();
- //$("#name_status").html("Mobile exist, Use different mobile no.");
- return false;
- }
- else if(!filter.test(email)) {
- alert("Please Enter Valid Email id");
- document.forms["PestControl"]["email"].focus();
- return false;
- }
- else if(!validateEmail(email)) {
- document.forms["PestControl"]["email"].focus();
- return false;
- }
- else if (address == "") {
- alert("Address must be filled out");
- return false;
- }
- else if (description == "") {
- alert("Description must be filled out");
- document.forms["PestControl"]["description"].focus();
- return false;
- }
- else if(!validatePassword()){
- alert("password did not matched or blank password fields");
- document.forms["PestControl"]["password"].focus();
- return false;
- }
- else if($.trim(password) != $.trim(confirmpassword)){
- alert("password did not matched");
- document.forms["PestControl"]["password"].focus();
- return true;
- }
- else {
- document.PestControl.action = "medical_college_process.php?trans=addcollege";
- document.PestControl.method = "post";
- document.PestControl.submit();
- }
- }
- function validatePassword(){
- var password= document.forms["PestControl"]["password"].value;
- var confirmpassword= document.forms["PestControl"]["confirmpassword"].value;
- var Exist = false;
- if((password.value === '') && (confirm_password.value==='')) {
- alert();
- Exist = false;
- }
- else if(password.value != confirm_password.value) {
- Exist = false;
- }
- else {
- Exist = true;
- }
- async:false;
- return Exist;
- }
- function validateEmail(email){
- var Exist = false;
- $.ajax({
- type:"post",
- dataType:"json",
- url:"email_validation.php",
- data:"email="+email,
- success: function(data)
- {
- if(data.success=="0")
- {
- alert("Email Already Exist With Us..!");
- Exist = false;
- }
- else{
- Exist = true;
- }
- },
- async:false
- });
- return Exist;
- }
- function validatePhone(phone){
- //alert(phone);
- var Exist = false;
- $.ajax({
- type:"post",
- dataType:"json",
- url:"email_validation.php",
- data:"phone="+phone,
- success: function(data)
- {
- if(data.success=="0")
- {
- alert("Number Already Exist With Us..!");
- //$("#mobile").focus();
- Exist = false;
- }
- else{
- Exist = true;
- }
- },
- async:false
- });
- return Exist;
- }
- </script>
- <div class="form-group col-md-12" style="text-align: right;margin-top: 10px;">
- <label style="margin-bottom: 0px;">Confirm Password </label>
- <input id="confirm_password" type="password" class="form-control" name="confirmpassword" value="">
- </div>
- <div class="col-md-12" style="text-align: right;margin-top: 10px;">
- <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