I am trying to validate my form information using javascript. My form has an amount value that must be entered as a number. I am trying to make it so a number must be inputted but I cannot quite get down the issue I am having with my javascript function
<form name="formname" onsubmit="return checkNumInput()" action="nextpage.php" method="post">
function checkNumInput(){
number.constructor;
var amount = document.forms["formname"]["amount"];
if(Number.isNaN(amount.value)){
window.alert("amount must be a number");
amount.focus();
return false;
}
return true;
}
<input type="number">and the user won't be able to enter anything but numbers.Number.isNaNonly checks to see if the passed value is===NaNnot if something cant be converted to a number. You probably meant to use the globalisNaNnumber.constructor;do?