Cobra23 Posted March 2, 2019 Share Posted March 2, 2019 (edited) 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 Edited March 2, 2019 by Cobra23 Quote Link to comment https://forums.phpfreaks.com/topic/308413-jquery-way-to-blocktrim-more-than-one-zeros/ Share on other sites More sharing options...
requinix Posted March 2, 2019 Share Posted March 2, 2019 Don't allow multiple consecutive zeros, or do but reduce them, but do allow multiple consecutive zeros after a number? What? What are some examples of good and of bad values, and what makes them good or bad? Quote Link to comment https://forums.phpfreaks.com/topic/308413-jquery-way-to-blocktrim-more-than-one-zeros/#findComment-1564973 Share on other sites More sharing options...
Cobra23 Posted March 2, 2019 Author Share Posted March 2, 2019 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]+)$/ Quote Link to comment https://forums.phpfreaks.com/topic/308413-jquery-way-to-blocktrim-more-than-one-zeros/#findComment-1564974 Share on other sites More sharing options...
requinix Posted March 2, 2019 Share Posted March 2, 2019 (edited) So what you meant is that you want to validate a positive integer without leading zeroes? Then yes, that will do it; my answer would have been /^(0|[1-9]\d*)$/ but that's basically the same thing. Edited March 2, 2019 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/308413-jquery-way-to-blocktrim-more-than-one-zeros/#findComment-1564975 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.