SoFunction
Updated on 2025-02-28

Example of use of js [i]


//Check whether the form element is empty
function check(Form)
{
for (i=0;i<;i++){
if([i].value == "")
{
//The first character of Form attribute elements is lowercase
alert([i].name + "can't be empty!");
[i].focus();
//Specify form elements to get focus
return;
}
}
();
}
Call
<form name="form1" method="post" action="">
Message: <input type="text" name="mname" size="20">
Message topic: <input type="text" name="mtext" size="66">
Message content: <textarea name="mnote" cols="64" rows="10" class="wenbenkuang"></textarea>
<input name="Button" type="button" class="btn_grey" value="Submit"
onClick="check(form1)">
<input name="Submit2" type="reset" class="btn_grey" value="Reset">
</form>