Forum Replies Created

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • in reply to: Validating fields as we type. #17183
    pajura
    Participant

    in reply to: Hide Submit button on condition #15551
    pajura
    Participant

    sent via e-mail!

    in reply to: Validating fields as we type. #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

    in reply to: errors on page trigger custom validation as invalid #15492
    pajura
    Participant

    Yes, silly me!
    Thanks!

    in reply to: Validating fields as we type. #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.

    in reply to: validation before send #15468
    pajura
    Participant

    Thank you for your reply.
    I did spend some time using jquery to validate fields one by one from one “page” to another but it is not very friendly.

    Hopefully in the future version!

Viewing 6 posts - 1 through 6 (of 6 total)
Be inspired. © 2025 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy