How can I run through all the inputs in my form to validate them for the same condition?

Can I use the form.elements

Something like:
for i = 0 to form.elemets.count
if form.elements(i).value = "" then
window.alert "Enter data!"
end if
next

It gives me an error stating that object doesnt support this property. What is wrong or what other way is there to do it?
I Have alot of textboxes on my form and dont want to check each on inividualy!