Validating a data input javascript -
i have been looking validate data input check whether integer or string. looked around , saw suggestions , typeof
suggestions nothing seems work.
var nam = prompt("enter name:") person.push(nam); var mk1 = prompt("enter mark 1:"); var mk1 = parseint(mk1); mark1.push(mk1);
if want check whether input string not number try this:
if (isnan(parseint(name, 10)) { //name string } else { //name number }
Comments
Post a Comment