Making a customized error based off inputs

  • 14 January 2014
  • 0 replies
  • 560 views

What code can I use to throw an error when a user enters in incorrect data?
Just like when a user does not enter in data for a required field, I would like to make it so they have to make a certain field contain certain values.
If they enter a decimal value for price, how would I be able to prevent them from submitting?

if (input.indexOf(".") !== -1){   
alert("You can't have decimal values");   
}   

Thank you.


0 replies

Be the first to reply!

Reply