Portekoi
Portekoi

Reputation: 1147

Jquery validate and Mask for decimal and thousands separator

I use the plugins Validate and mask.

In an input field, I need allow these formats of numbers:

123,12 1 234,99 687 542,85

i've try this options : "required": true,
"number": true

How can i do it?

Upvotes: 0

Views: 2653

Answers (1)

Portekoi
Portekoi

Reputation: 1147

I find my answer :

$.validator.methods.number = function (value, element) {
            return this.optional(element) || /\d{1,3}(\.\d{3})*(\.\d\d)?|\.\d\d/.test(value);
        }

And then :

$("#myform").validate({
            ignoreTitle: true,
            rules: {
                "myfield": {
                    "required": true,                       
                    "number": true

                }, ....

Upvotes: 1

Related Questions