Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Alphabets with special character (only apostrophe ‘ and space allowed)
- $.validator.addMethod(
- "alpa_asp_sp",
- function (value, element) {
- return this.optional(element) || /^[a-zA-Z ']+$/i.test(value);
- },
- "Only apostrophe ‘ and space allowed."
- );
- // Alphanumeric with special character (only back slash / allowed)
- $.validator.addMethod(
- "alpnum_bck_sls",
- function (value, element) {
- return this.optional(element) || /^[a-zA-Z0-9/']+$/i.test(value);
- },
- "Only back slash / allowed."
- );
- // Alphanumeric with special character no space Allowed
- $.validator.addMethod(
- "alpnum_specil_no_space",
- function (value, element) {
- return this.optional(element) || /^[a-zA-Z0-9/'"._^%$#!~@,-=+*]+$/i.test(value);
- },
- "Space not allowed."
- );
- // alphanumeric and hyphen
- $.validator.addMethod(
- "alpnum_dash",
- function (value, element) {
- return this.optional(element) || /^[a-zA-Z0-9-]+$/i.test(value);
- },
- "Alphanumeric with special character (only hyphen allowed)."
- );
- // Alphanumeric with special characters (/ - allowed )
- $.validator.addMethod(
- "alpnum_slas_dash",
- function (value, element) {
- return this.optional(element) || /^[a-zA-Z0-9-/]+$/i.test(value);
- },
- "Alphanumeric with special characters (/ - allowed )."
- );
- // date
- $.validator.addMethod(
- "greaterThan",
- function (value, element, params) {
- if (!/Invalid|NaN/.test(new Date(value))) {
- return new Date(value) > new Date($(params).val());
- }
- return (isNaN(value) && isNaN($(params).val())) || Number(value) > Number($(params).val());
- },
- "Date Must be greater than {0}."
- );
- //date
- $.validator.addMethod(
- "lessThan",
- function (value, element, params) {
- if (!/Invalid|NaN/.test(new Date(value))) {
- return new Date(value) <= new Date($(params).val());
- }
- return (isNaN(value) && isNaN($(params).val())) || Number(value) <= Number($(params).val());
- },
- "Date Must be less than {0}."
- );
- $("#art_registration_form").validate({
- ignore: ":not(:visible)",
- focusCleanup: true,
- onfocusout: function (element) {
- this.element(element);
- },
- rules: {
- patient_name: {
- required: true,
- // maxlength: 50,
- // minlength: 3,
- alpa_asp_sp: true,
- three_min_fifty_max: true,
- },
- date_of_registration: {
- required: true,
- },
- },
- onkeyup: function (element) {
- this.element(element);
- },
- messages: {
- patient_name: {
- required: "Patient Name is Required.",
- asp_sp: "Only apostrophe ‘ and space allowed.",
- },
- date_of_registration: {
- required: "Date of Registration is Required.",
- },
- },
- });
Add Comment
Please, Sign In to add comment