Chintan Soni
Chintan Soni

Reputation: 25267

javascript : validate price with some constraints

So, I want to validate price that user enters in my text field:

<input type="number" name="AdsCharges" placeholder="0.00" id="charges">

Conditions(or constraints):

  1. Value should always always be greater than zero
  2. Value cannot contain minus "-"
  3. Value cannot contain decimal points more than once. Also value should not start with decimal point

Also, I have to keep in mind that this should be working on mobile too, as the app is going to be Phonegap based.

Thanks.

Edit: I tried this code, from here. But what happens is that, on web browsers (desktop), they work perfectly, I mean, dots are not allowed more than once. But, when I use it in my phonegap app, it is allowing multiple dots.

Upvotes: 0

Views: 452

Answers (1)

Amit Prajapati
Amit Prajapati

Reputation: 14315

Try this :

<input type= "number" name= "five_steps" max= "30" min= "0" step= "5" value= "10" />

Upvotes: 1

Related Questions