using .trim() with jquery validate plugin

I am using jQuery Live Form Validation from GeekTantra

The validation is called by ID. Here is the code I use to set the options for a field that is a 2 digit number less than 50:

jQuery("#ValidNumber2Digits50").validate({
        expression: "if (VAL.length <= 2 && !isNaN(VAL) && VAL < 50) return true; else return false;",
        message: "Please enter a 2 digit number less than 50"
    });

The only problem is that it counts white spaces in the length. S0...

_4 ==> good data 
4_==> good data
_9_ ==> bad data 
_ _2 ==> bad data

I tried:

if (VAL.trim.length <= 2 && !isNaN(VAL) && VAL < 50) return true; else return false;

which did not work.

Any ideas?

Thanks in advance.

Answers


trim() is a function - try using $.trim(VAL).length instead.


Need Your Help

Google Maps API IOS cannot load new coordinates with custom UIView

ios swift google-maps google-maps-sdk-ios gmsmapview

I have a problem with loading coordinates for a custom UIView that has been linked through IBOutlet and subclassed as GMSMapView. The mapView loads but it always shows the wrong location every time (

Disable rotation in UIImagePicker

iphone objective-c ios5 uiimagepickercontroller

Hello I need to disable the rotation of the UIImagePicker.