<!DOCTYPE html>
<html>
<head><title> Validation </title>
<script>
function checking() {
if (document.test.iud.value.length < 2 || document.test.iud.value.length > 3) {
window.alert("User ID must have 2 to 3 characters only");
return false;
}
else {
if (document.test.price.value < 1 || !isNumber(document.test.price.value)) {
window.alert("The price must be a positive value");
return false;
}
else {
if (document.test.quan.value < 20) {
window.alert("The minimum amount of items is 20.")
return false;
}
else {
if (document.test.status.value == undefined) {
window.alert("You must select a status.");
return false;
}
else
return true;
}
}
}
}
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
</script>
</head>
<body>
<form name=test onsubmit="return checking()">
Enter User ID <br><input type=text name=iud size=30><br>
Enter price of items <br><input type=text name=price size=30><br>
Enter amount of items <br><input type=text name=quan size=30><br>
Select Status <br><input type="radio" value="1" name="status"/>Normal
<br><input type="radio" value="1" name="status"/>Advance
<br>
<input type=submit value="Submit">
<input type=reset value="clear all">
</form>
</body>
</html>