Hallo,
function checkFriendsMails(){
//alert(document.forms[0].email_4.value);
var i;
var mails = new Array("email_1", "email_2", "email_3", "email_4");//alert(mails.length);
for(i=0; i<mails.length; i++){
alert(mails[i]);
if (document.forms[0].mails[i].value == "") alert('Plese fill in the Fields');
// ^hier versuchst Du eine Eigenschaft mails anzusprechen, welche das Form-Element aber nicht hat.
else alert('That is fine, go a head');
}
}
Ich nehme an, Du willst nacheinander die Elemente mit den namen "email\_1", "email\_2", "email\_3", "email\_4" ansprechen?, dann:
> ~~~javascript
> function checkFriendsMails(){
> //alert(document.forms[0].email_4.value);
> var i;
> var mails = new Array("email_1", "email_2", "email_3", "email_4");
>
> //alert(mails.length);
>
> for(i=0; i<mails.length; i++){
> alert(mails[i]);
if (document.forms[0].elements[mails[i]].value == "") alert('Please fill in the Fields');
> else alert('That is fine, go a head');
> }
> }
>
Siehe auch http://de.selfhtml.org/javascript/objekte/elements.htm#allgemeines dort Schema 4 / Beispiel 4.
viele Grüße
Axel