views:

90

answers:

2

I am using the maxlength function of jquery.validate.js plugin to validate for mobile number. as following

txtMobileNo: {

            number : true,  
            minlength: 10,
            maxlength: 12
},

and in mysql description of this field is as following...

mobile_no int(11)

when i enter any valid mobile number it store only this value "2147483647"..

A: 

It doesn't sound like the problem is with your validation, but rather your actual code to store a value in the database. Remove the jQuery validation. Try it again. I bet you still get the same error.

2147483647 is the maximum value of a 32-bit signed integer. If you're trying to store 10-12 digit long mobile numbers in a 32-bit signed integer field, you're almost always going to overflow.

You should almost certainly use varchar(12) or something like that for your database representation.

Carson63000
Thx Carson63000 for rpying. ya it is the problem of overflow. i changed the datatype and now its working fine.Thanks again.
A: 

I agree with @Carson63000, although a phone number is made of numbers, it has no numeric value (for example, try storing a number that starts with a 0), so you should hold the number with its string representation, more specifically, varchar or even char if they have a fixed length.

scripni