is there a way to make a function that can take multiple values and put them into an array? like this:
function check(val) {
var i = 0
var submit = 'true'
for (i in val) {
if (val == '')
submit = 'false'
i++
}
if (submit == 'false') {
alert('One or more of the fields were left blank.')
return false
} else
return true
}
the html form code would be this:
<form onsubmit="return check(document.forms[0].inputName1.value, document.forms[0].inputName2.value">
ive tried this code and it doesnt work, is there a way to make val in function check(val) become an array that holds document.forms[0].inputName1.value and document.forms[0].inputName2.value at array addresses 0 and 1?
function check(val) {
var i = 0
var submit = 'true'
for (i in val) {
if (val == '')
submit = 'false'
i++
}
if (submit == 'false') {
alert('One or more of the fields were left blank.')
return false
} else
return true
}
the html form code would be this:
<form onsubmit="return check(document.forms[0].inputName1.value, document.forms[0].inputName2.value">
ive tried this code and it doesnt work, is there a way to make val in function check(val) become an array that holds document.forms[0].inputName1.value and document.forms[0].inputName2.value at array addresses 0 and 1?