Validating fields as we type.

Home Forums Quform WordPress Validating fields as we type.

This topic is: resolved
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #15446
    Harrison
    Participant

    Is it possible to validate the fields as we type? is there any function available for that? I know I can use the tooltip to give information, but I was looking for the possibility to validate instead.
    Thanks.

    #15447
    Harrison
    Participant

    I just found some hooks https://support.themecatcher.net/quform-wordpress/guides/hooks/iphorm_pre_validate not sure if that will do, but could anyone give me an example on what to add inside the hook? I’ve no clue on what the custom code will be.

    function my_pre_validate($form)
    {
    // Custom code
    }
    add_action('iphorm_pre_validate', 'my_pre_validate');

    #15461
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #15473
    pajura
    Participant

    I use this http://jqueryvalidation.org/ to validate a field as is typed.

    But to actually be validated once more during submit I recreated the validation with custom validation in PHP.

    #15477
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #15500
    pajura
    Participant

    here is a piece of code that works with the above script to validate a “Romanian Personal Number” CNP as you type


    // check valid CNP as we type
    $.validator.addMethod("roCNP", function(value, element) {
    var check = false;
    var re = /^\d{1}\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])(0[1-9]|[1-4]\d| 5[0-2]|99)\d{4}$/;
    if( re.test(value)) {
    var bigSum = 0, rest = 0, ctrlDigit = 0;
    var control = '279146358279';
    for (var i = 0; i < 12; i++) {
    bigSum += value[i] * control[i];
    }
    ctrlDigit = bigSum % 11;
    if ( ctrlDigit == 10 ) ctrlDigit = 1;

    if ( ctrlDigit != value[12] ) return false;
    else return true;

    } return false;
    },
    "CNP invalid"
    );

    $('.iphorm-form-1').validate({ // initialize the validation
    rules: {

    iphorm_1_1: { //CNP
    required: true,
    // number: true,
    roCNP: true
    }

    }

    });

    the script needs to enqueued in WP and the above code added in a .js file

    #15782
    Harrison
    Participant

    Thanks for all the help!

    #17182
    mdadan1
    Participant

    Hi pajura,
    Can I have your email address ? I wish to ask you more about rom. CNP validation.
    Regards,
    Daniel titan

    #17183
    pajura
    Participant

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy