Jump to content

jQuery way to block/trim more than one zeros


Cobra23

Recommended Posts

Hi,

Is there a jQuery validator way to block two or more 0's input and allow one 0. Or even trim the inputs like 00 or 000 or 0000 or 00000 etc and replace it with 0. But I also, want to allow all 0's after a positive number.

I can do it on server side no problem but in the jQuery validator i am struggling to do this.

Thanks

Link to comment
Share on other sites

Yes, not to allow multiple zeros in one input box without another positive digit. It is a case of the client validation notifying the user of their input being wrong eg bootstraps red highlighted input boxes that notifies the user of the input being wrong and needs to be sorted. Inputs of two or more 0's only should not be allowed in this case.

Anyways, I got this sorted with the following regex.

/^([0]|[1-9]|[1-9][0-9]+)$/

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.