JQuery Validation.js

I am using jQuery validation.js to validate a few fields on my site, when submitted.  I am wondering if anyone was familiar with how you can make a number value limit?

My Script:
<script>
jQuery.validator.addMethod(
			"regex",
			function(value, element, regexp) {
				var re = new RegExp(regexp);
				return this.optional(element) || re.test(value);
			},
			"Incorrect format; Please check your input.");


$(document).ready(function(){
		$("#update_cart_form").validate({
errorElement: 'div',
			rules: {
				"item_options[association_membership]": {
					required: true	
				},
				"item_options[purchase_price]": {
					digits: true
				},
				"item_options[accessories_value]": {
					digits: true
				},
				"item_options[contact_email]": {
					email: true,
					regex: "^((\"[\\w\\s-]+\")|([\\w-]+(?:\\.[\\w-]+)*)|(\"[\\w\\s-]+\")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-zA-Z]{2,6}(?:\\.[a-zA-Z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)"

				}
			},

			messages: {

				"item_options[association_membership]": {
					required: "Please Choose A Membership",
					
				},
				"item_options[purchase_price]": {
					digits: "Only a numeric value allowed."
				},
				
				"item_options[accessories_value]": {
					digits: "Only a numeric value allowed."
				},
				"item_options[contact_email]": {
					 email: "Please enter a valid email address",
					 regex: "Please enter this particular format of email address"
				}		

			}
		});
			
	});
</script>

Open in new window


Under                   "item_options[purchase_price]": {
                              digits: true
                        },

I would like to add something like:
                  "item_options[purchase_price]": {
                              digits: true,
                                        number limit: 5000
                        },
So that they can not add in a number larger than 5000.  Does that make sense?
LVL 7
rgranlundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
are you talking about this plugin?
http://jqueryvalidation.org/

Then you should use the max method:
http://jqueryvalidation.org/max-method/

"item_options[purchase_price]": {
                              digits: true,
                                        max: 5000
                        },

Open in new window


HTH
Rainer
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgranlundAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.