victorjonsson / jQuery-Form-Validator

[DISCONTINUED] jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code.
973 stars 477 forks source link

How to ignore commas from number validation #715

Closed lynspod closed 5 years ago

lynspod commented 5 years ago

I'm using data-validation-ignore="," on an text input field with data-validation="required number" I would like it to ignore commas in the field, but data-validation-ignore="," doesn't seem to work, should this work or is there s different syntax as I can see commas are used to separate characters here?

Seems to allow one comma but more than one comma, it doesn't validate.

victorjonsson commented 5 years ago

Am I right that you want the user to be able to supply a comma separated list with numbers? The number validator does not understad that the input field will contain several numbers to be validated. In this case you need to do a custom validation.

<input data-validation="required custom" 
           data-validation-regexp="^([0-9, ]+)$">

Here's an example: https://jsbin.com/xecoxaqosa/edit?html,output

lynspod commented 5 years ago

Many thanks, that's just what I wanted.