I am trying to make this function:
function check()
{
for (var i=0;i<document.form1.length;i++){
if (document.form1.elements.value==""
{
alert("Please enter your name."
;
document.form1.elements.focus();
break;
I used to call it document.form1.name.value but if I want to change it to elements. what is the proper syntax if there are 2 elements that I should check in the whole form?
Let say, if I there are two fields, such as name and adrress. What is the correct syntax in using elements to specify each element?
Thank you.
function check()
{
for (var i=0;i<document.form1.length;i++){
if (document.form1.elements.value==""
{
alert("Please enter your name."
document.form1.elements.focus();
break;
I used to call it document.form1.name.value but if I want to change it to elements. what is the proper syntax if there are 2 elements that I should check in the whole form?
Let say, if I there are two fields, such as name and adrress. What is the correct syntax in using elements to specify each element?
Thank you.