﻿function loadValidations() {
    var searchPropertyForm = $('#SearchPropertyForm');
    var val = searchPropertyForm.validate({
        rules: {
            Parcel: {
                maxlength: 7,
                minlength: 7
            },
            Owner_Name:{            
                minlength: 3
            },            
            Full_Property_Location:{            
                minlength: 3
            }
        },
        messages: {
            Parcel: {
                maxlength: "Parcel Number should be 7 characters long and should have only characters or numbers",
                minlength: "Parcel Number should be 7 characters long and should have only characters or numbers"
            },
            Owner_Name: {
                minlength: "Owner Name should be at least 3 characters and should not contain %"
            },
            Full_Property_Location: {
                minlength: "Address Name should be at least 3 characters and should not contain %"
            }
        }
    });
    $("#Parcel").rules("parcelNo", { regex: "^[0-9a-zA-Z]{7,}$" });
    $("#Owner_Name").rules("ownerName", { regex: "^[0-9a-zA-Z]$" });
    $("#Full_Property_Location").rules("fullAddress", { regex: "^[0-9a-zA-Z]$" });
}
$.validator.addMethod("parcelNo", function(value, element, regexp) { var check = false; var re = new RegExp(regexp); return this.optional(element) || re.test(value); }, "Parcel Number should be 7 characters long and should have only characters or numbers");
$.validator.addMethod("ownerName", function(value, element, regexp) { var check = false; var re = new RegExp(regexp); return this.optional(element) || re.test(value); }, "Owner Name should be at least 3 characters and should not contain %");
$.validator.addMethod("fullAddress", function(value, element, regexp) { var check = false; var re = new RegExp(regexp); return this.optional(element) || re.test(value); }, "Address should be at least 3 characters and should not contain %");