javascript - How to check if a comma was used in an input tag? -
i have few input tags, , ajax script converts values string separated commas before sending php script. if uses comma in input tags, breaks read method, values broken. tags aren't meant text, , there no reason use one, in case, how check if user used comma, using jquery.
ideally, want:
$('element').keyup(function(event) { if(){//previous value comma alert('commas not allowed!!'); //code delete comma } });
thanks.
you can use indexof on value of current input value.
if(this.value.indexof(',') !== -1) { //comma in input not allowed }
Comments
Post a Comment