jQuery: The Write Less, Do More JavaScript Library

jQuery Validation request

View: New views
4 Messages — Rating Filter:   Alert me  

jQuery Validation request

by Richard-330 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

I was working with validation, but am having problems using the method
"max" for maximal numbers. I live in Holland and for us the decimal
character is a comma, and I can use comma's for validating the max
value of a field.
Could someone please make an addon like "numberDE" for max? So i can
check comma's.

Thanks!

Richard

Re: jQuery Validation request

by Bart van Uden :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Richard,

I also live in the Netherlands and ran into the same problem. I couldn't find an answer online so i decided to write some addon methods myself.
I added the following two methods to the validator and that did the trick.

$.validator.addMethod("maxNL", function(value, element, param) {
    var val = value.replace(",", ".");
    return this.optional(element) || val <= param;
}, jQuery.validator.format("Vul hier een waarde in kleiner dan of gelijk aan {0}."));

$.validator.addMethod("minNL", function(value, element, param) {
    var val = value.replace(",", ".");
    return this.optional(element) || val >= param;
}, jQuery.validator.format("Vul hier een waarde in groter dan of gelijk aan {0}."));

It doesn't do much more than replace a comma with a period and validate the new value.
Hope this helps.
Note that this probably doesn't work for numbers greater than 1000 with formatting (for example, 1.000,00). In that case you have to switch the period for a comma and the comma for a period.

Greets,
Bart

Richard-330 wrote:
Hi,

I was working with validation, but am having problems using the method
"max" for maximal numbers. I live in Holland and for us the decimal
character is a comma, and I can use comma's for validating the max
value of a field.
Could someone please make an addon like "numberDE" for max? So i can
check comma's.

Thanks!

Richard

Re: jQuery Validation request

by nathan-90 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all
 Who can tell me how to unsubscribe this mailling list?
I'm gonna use another account for this mailing list.
thanks


--
View this message in context: http://old.nabble.com/jQuery-Validation-request-tp25995270s27240p26160052.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.




Re: jQuery Validation request

by Karl Swedberg-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


The following instructions are paraphrased from:

You can unsubscribe from a group through the web interface or via email. To unsubscribe through the web interface, just click the "Edit my membership" link on the right-hand side of the group's homepage at http://groups.google.com/group/jquery-en/. Then click the "Unsubscribe" button on the page that appears.

To unsubscribe via email, send an email to jquery-en+unsubscribe@...

--Karl

____________
Karl Swedberg




On Nov 4, 2009, at 12:07 AM, NathanHuang wrote:

Hi all
 Who can tell me how to unsubscribe this mailling list?
I'm gonna use another account for this mailing list.
thanks


--
View this message in context: http://old.nabble.com/jQuery-Validation-request-tp25995270s27240p26160052.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.