Ik ben nu al een tijdje bezig om een formulier werkend te krijgen in FireFox en Safari. De validatie wil maar niet lukken.
De code is misschien niet echt zoals het hoort, maar dit is dan ook een 'samenstelling' van alles wat ik via Google gevonden heb. Ik heb reeds al een formulier gemaakt met alert boxen ipv inline validatie. Dit heb ik uiteindelijk werkend gekregen. Maar deze maal kom ik er niet uit... In IE7 werkt alles perfect.
[code=Javascript]
function GetSelectedItem() {
sel = ""
len = document.request.routerv.length
for (i = 0; i <len; i++) {
if (document.request.routerv[i].checked) {
sel = document.request.routerv.value}
}
if (sel == "") {return false}
else {return true}
}
function CheckForm()
{
name = document.getElementById("name").value;
email = document.getElementById("email").value;
AtPos = email.indexOf("@")
StopPos = email.lastIndexOf(".")
bdmac = document.getElementById("bdmac").value;
routerv = document.getElementById("routerv").value;
if (name==null||name == "") {
hideAllErrors();
document.getElementById("nameError").style.display = "inline";
document.getElementById("name").select();
document.getElementById("name").focus();
return false;
}
else if (email==null||email == "") {
hideAllErrors();
document.getElementById("emailError1").style.display = "inline";
document.getElementById("email").select();
document.getElementById("email").focus();
return false;}
else if (AtPos == -1 || StopPos == -1 || StopPos < AtPos || StopPos - AtPos == 1) {
hideAllErrors();
document.getElementById("emailError2").style.display = "inline";
document.getElementById("email").select();
document.getElementById("email").focus();
return false;
}
else if (bdmac==null||bdmac == "") {
hideAllErrors();
document.getElementById("bdmacError").style.display = "inline";
document.getElementById("bdmac").select();
document.getElementById("bdmac").focus();
return false;
}
else if (GetSelectedItem()==false)
{
hideAllErrors();
document.getElementById("routervError").style.display = "inline";
return false;
}
return true;
}
function hideAllErrors() {
document.getElementById("nameError").style.display = "none"
document.getElementById("emailError1").style.display = "none"
document.getElementById("emailError2").style.display = "none"
document.getElementById("bdmacError").style.display = "none"
document.getElementById("routervError").style.display = "none"
}
De code is misschien niet echt zoals het hoort, maar dit is dan ook een 'samenstelling' van alles wat ik via Google gevonden heb. Ik heb reeds al een formulier gemaakt met alert boxen ipv inline validatie. Dit heb ik uiteindelijk werkend gekregen. Maar deze maal kom ik er niet uit... In IE7 werkt alles perfect.
[code=Javascript]
function GetSelectedItem() {
sel = ""
len = document.request.routerv.length
for (i = 0; i <len; i++) {
if (document.request.routerv[i].checked) {
sel = document.request.routerv.value}
}
if (sel == "") {return false}
else {return true}
}
function CheckForm()
{
name = document.getElementById("name").value;
email = document.getElementById("email").value;
AtPos = email.indexOf("@")
StopPos = email.lastIndexOf(".")
bdmac = document.getElementById("bdmac").value;
routerv = document.getElementById("routerv").value;
if (name==null||name == "") {
hideAllErrors();
document.getElementById("nameError").style.display = "inline";
document.getElementById("name").select();
document.getElementById("name").focus();
return false;
}
else if (email==null||email == "") {
hideAllErrors();
document.getElementById("emailError1").style.display = "inline";
document.getElementById("email").select();
document.getElementById("email").focus();
return false;}
else if (AtPos == -1 || StopPos == -1 || StopPos < AtPos || StopPos - AtPos == 1) {
hideAllErrors();
document.getElementById("emailError2").style.display = "inline";
document.getElementById("email").select();
document.getElementById("email").focus();
return false;
}
else if (bdmac==null||bdmac == "") {
hideAllErrors();
document.getElementById("bdmacError").style.display = "inline";
document.getElementById("bdmac").select();
document.getElementById("bdmac").focus();
return false;
}
else if (GetSelectedItem()==false)
{
hideAllErrors();
document.getElementById("routervError").style.display = "inline";
return false;
}
return true;
}
function hideAllErrors() {
document.getElementById("nameError").style.display = "none"
document.getElementById("emailError1").style.display = "none"
document.getElementById("emailError2").style.display = "none"
document.getElementById("bdmacError").style.display = "none"
document.getElementById("routervError").style.display = "none"
}