Let's say, user input on prompt is 1 so JavaScript will create one textfield.
We'll test Assess() if its working. Type "1" on textField and click "Assess" button.
No alert message appears.
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">
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);
document.write("<form name=\"myForm\" action=\"\"><font>");
var txt1 = "<input type=\"text\" name=\"t>";
var txt2 = "\"></input><br/><br/>";
for (i=1;i<=inp;i++){
document.write("TextField # " + i + " " + txt1 + i + txt2);//creates textfields depending upon the "inp" variable
}
function Assess(){
var g = document.myForm.t1.value;
if (g==1){
alert("Invalid input found at TextField # 1.");
}
}
</script>
</head>
<body>
<input type="button" value="Assess" onClick="Assess()"/>
</font></form><!--Closes form and font tag from javascript-->
</body>
</html>