I created a function wherein if a textField has no value/input, it will prompt an alert.
However, the function is not working. Things I consider that makes it not work:
1) the "inp" variable
2) declaration at <form> tag
3) looping the all the textfields
What do you think? Please help. Thanks in advance.
<html>
<head>
<title>JavaScript</title>
<style type="text/css">
font{
color:#663300;
font-variant:small-caps;
font-family:calibri;
font-size:15;
}
</style>
<script type="text/javascript">
function Assess(){
var g ;
for (x=0;x<inp;x++){
g = document.formKo.BoxText[x].value;
if (g==""){
alert("No input found at TextField # ." + g);
}
}
}
</script>
</head>
<body>
<font>
<form id="formKo" action="JavaScript:Assess()">
<script type="text/javascript">
var n = '\n';
var inp;
do{
inp = prompt("Number of inputs to assess." + n + n + "Maximum of 10.");//asks user how many input will the program assess
}while (inp > 10 || inp <=0);
var txt = "<input type='text' name='BoxText'/><br/><br/>";
for (i=1;i<=inp;i++){
document.write("TextField # " + i + " " + txt );//creates textfields depending upon the "inp" variable
}
</script>
<input type="submit" name="submit" value="Submit"/>
<input type="reset" name="reset" value="Reset"/>
</form>
</font>
</body>
</html>