• Home
  • Plugins
    • Use Any Font
    • WP Masonry Layout
    • Jquery Validation For Contact Form 7
    • Real Email Checker
    • Any Mobile Theme Switcher
    • Block Specific Plugin Updates
    • Featured Image in RSS Feed
    • Add Tags And Category To Page
    • Remove Admin Bar For Client
  • Support Forum
  • Blog
  • Contact
  • Home
  • Plugins
    • Use Any Font
    • WP Masonry Layout
    • Jquery Validation For Contact Form 7
    • Real Email Checker
    • Any Mobile Theme Switcher
    • Block Specific Plugin Updates
    • Featured Image in RSS Feed
    • Add Tags And Category To Page
    • Remove Admin Bar For Client
  • Support Forum
  • Blog
  • Contact
  • You are here:
  • Home
  • Jquery Validation for Contact Form 7
  • How to extend with own rules

Home › Forums › Jquery Validation for Contact Form 7 › How to extend with own rules

This topic contains 0 replies, has 1 voice, and was last updated by  Stanislaw Nalepa 3 years, 8 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • January 4, 2015 at 4:17 pm #3888

    Stanislaw Nalepa

    Hello Dinesh.

    I have tested an extension to jQuery Validation, in JSFiddler it works as expected. So now I wonder how I could integrate this function in your plugin “jquery validation for contact form 7”. the code below begins with two fields which were in the example already, it is the third field that runs the validation I need in my form.

    /*
    $(document).ready(function () {

    $(‘#myform’).validate({
    rules: {
    field1: {
    required: true,
    integer: true
    },
    field2: {
    required: true,
    integer: true
    },
    field3: {
    required: true,
    myPersonnummerkoll: true
    }
    },
    submitHandler: function (form) { // for demo
    alert(‘valid form’);
    return false;
    }
    });

    jQuery.validator.addMethod(‘integer’, function (value, element, param) {
    return (value != 0) && (value == parseInt(value, 10));
    }, ‘Please enter a non zero integer value!’);
    $.validator.addMethod(“myPersonnummerkoll”, function(value, element) {
    var pnr = value;
    // Do formatting and sanity control
    pnr = pnr.replace(/[^0-9]/g, ”); // only keep digits
    if (12 == pnr.length) // year format 1985 → 85
    pnr = pnr.substr(2);
    if (10 != pnr.length) // check length
    return false;
    if (pnr.substr(2,2) > 12) // check month
    return false;
    if (pnr.substr(4,2) > 31 || pnr.substr(4,2) == 0) // check date
    return false;
    var parts = pnr.split(”).map(function(i){
    return Number(i);
    });
    // Then run the mod 10 algorithm to produce check digit
    var control = parts.pop();
    var inc = 0, multiplicator = 2, product;
    for (var i in parts) {
    product = parts[i] * multiplicator;
    if (product > 9)
    inc += product – 9;
    else
    inc += product;
    multiplicator = multiplicator == 1 ? 2 : 1;
    }
    var control_ = 10 – (inc – Math.floor(inc/10)*10);
    if (10 == control_)
    control_ = 0;
    if (control == control_)
    return true;
    }, “Personnumret är ofullständigt eller i fel form!”);
    });*/

  • Author
    Posts
Viewing 1 post (of 1 total)

The topic ‘How to extend with own rules’ is closed to new replies.

Our Plugins
  • Use Any Font
  • WP Masonry Layout
  • Jquery Validation For Contact Form 7
  • Real Email Checker
  • Any Mobile Theme Switcher
  • Block Specific Plugin Updates
  • Featured Image in RSS Feed
  • Add Tags And Category To Page
  • Remove Admin Bar For Client
Support Forum
  • Add Tags And Category to Page and Post Types
  • Any Mobile Theme Switcher
  • Block Plugin Updates
  • Email Checker
  • Featured Image in RSS Feed
  • Jquery Validation for Contact Form 7
  • Use Any Fonts
Scroll
Support Forums
  • Add Tags And Category to Page and Post Types
  • Any Mobile Theme Switcher
  • Block Plugin Updates
  • Email Checker
  • Featured Image in RSS Feed
  • Jquery Validation for Contact Form 7
  • Use Any Fonts
Recent Topics
  • Things don't appear to be working…
  • can't contribut
  • Menu Font
  • Multibple custon code validation
  • no fonts upload
  • error messages of missing required checkbox
  • One of the plugins won't block
Testing Platform Partner
Header logo

 

Follow Us
@2017 © Dnesscarkey