I was trying to validate Surname required field and NIC should only be in Numbers. But the problem is this code not checking NIC.
<script>
function validateform(SnameAddress,mail,NIC,dob){
var required=""
if(document.getElementById("Sname").value == ""){
alert("Surname : field is required");
return false;
}
}
function validateNIC(NIC){
var nic=document.getElementById("NIC").value;
if(isNaN(nic)){
alert("NIC : incorrect NIC num");
return false;
}
}
</script>
<form action="MAILTO:[email protected]" method="post" enctype="text/plain" action="#"
onsubmit="return (validateform() && validateNIC())">
Surname <input type="text" id="Sname" >
NIC <input type="text" id="NIC">
</form>
type="number"to NIC field ?isNaN(Number(nic))validateform()without param, and you define the function with param...Same asvalidateNIC()