Support » Developing with WordPress » [Plugin: Visual Form Builder] Digit validation

  • Resolved conflit-rgp

    (@conflit-rgp)


    Could you help me figuring out something? Is there a way to set a specified number or characters needed to validate the number field when specifying to validate digits?

    I want to use the “Number” field to collect ZIP codes validating for digits. But the “Number” field doesn’t have a limit for number of characters to check against. It will validate anything as as long as it is a digit.

    Would that be a rule I write in the my-js.js file? If so how?

    http://wordpress.org/extend/plugins/visual-form-builder/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Yes, you’d need to add a custom rule for that.

    http://docs.jquery.com/Plugins/Validation/#List_of_built-in_Validation_methods

    If you want to require a specific number of characters, you’d want to use minlength and maxlength.

    conflit-rgp

    (@conflit-rgp)

    jQuery(document).ready(function($) {
    $(“#vfb-zip-code-95”).validate({
    rules: {
    field: {
    required: true,
    minlength: 5,
    maxlength: 5
    }
    }
    });

    Here is the snippet I wrote out for the “Zip Code field on this page: http://www.styletrader.biz/signup/

    It still wont validate a min or max length of characters. I need your help haha.

    You are close.

    $("#newsletter-sign-up").validate({
    	rules: {
    		'vfb-zip-code-95': {
    			required: true,
    			minlength: 5,
    			maxlength: 5
    		}
    	}
    });
    conflit-rgp

    (@conflit-rgp)

    jQuery(document).ready(function($) {
        $.datepicker.setDefaults({
            dateFormat: 'mm-dd-yy',
            numberOfMonths: 1,
    		changeMonth: true,
    		changeYear: true,
    		yearRange: "c-90:c+1"
        });
    });

    This is a piece of code I already had in place in the “my-js.js file.

    I feel really dumb asking this, but how do I add this:

    $("#newsletter-sign-up").validate({
    	rules: {
    		'vfb-zip-code-95': {
    			required: true,
    			minlength: 5,
    			maxlength: 5
    		}
    	}
    });

    to what I currently have?

    jQuery(document).ready(function($) {
        $.datepicker.setDefaults({
            dateFormat: 'mm-dd-yy',
            numberOfMonths: 1,
    		changeMonth: true,
    		changeYear: true,
    		yearRange: "c-90:c+1"
        });
    
        $("#newsletter-sign-up").validate({
    	rules: {
    		'vfb-zip-code-95': {
    			required: true,
    			minlength: 5,
    			maxlength: 5
    		}
    	}
        });
    });
    conflit-rgp

    (@conflit-rgp)

    Thanks Matt! That did the trick.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Visual Form Builder] Digit validation’ is closed to new replies.