I have an input element in my form in which the user inputs price for a specific product. To do so he can either put an amount with decimal numbers or he can simply put a price without the decimal numbers.
<input type="text" id="product_price" name="product_price" maxlength="10" step="0.01" placeholder="Enter price">
$('#addForm').validate({
rules:{
product_name: {
required: true,
},
product_price: {
required: true,
number: true
}
}
})
This is what I did however I don't get what I wanted to achieve. I am trying to make it so that a user can put a number of length 10 up to two decimals. For example, if he enters 1111111111 or 1111111111.11 These both should be valid. What should I do and what be the code?
Thanks!