Jump to content

Recommended Posts

Does somebody know why this js doesn't work in IE?

 

<script type="text/javascript" >
function formValidation() {

var t1ck=true;
var msg=" ";

var naam1 = document.getElementById("t1").value ;
var naam2 = document.getElementById("t2").value;
var email = document.getElementById('email');
var filter = /^([a-zA-Z0-9_\.\-])+\@student.ua.ac.be+$/;
var emailBestaat = "";

// style voor als paswoorden matchen
if(naam1 != '' && naam2 != '' && naam1 == naam2) { document.getElementById("t1").style.border="1px solid green";
document.getElementById("t2").style.border="1px solid green";
document.getElementById("pwMatch").style.display="";
} else { document.getElementById("t1").style.border= "";
document.getElementById("t2").style.border= "";
document.getElementById("pwMatch").style.display="none";
}

// style voor als email goed is
if(filter.test(email.value)) {
document.getElementById("slecht").style.display="none";
document.getElementById("goed").style.display="inline";
}
//
else { document.getElementById("slecht").style.display="inline";
document.getElementById("goed").style.display="none";
}

if(email.value == ''){
document.getElementById("slecht").style.display="none";
document.getElementById("goed").style.display="none";
}

if(naam1 == '' || naam2 == '' || naam1 != naam2) { t1ck=false; }
if (!filter.test(email.value)) { t1ck=false;}
if(!document.getElementById("r1").checked && !document.getElementById("r2").checked){ t1ck=false;}
if(!document.getElementById("c1").checked ){ t1ck=false;}

if(t1ck){document.getElementById("btnSignUp").disabled = false;}
else{document.getElementById("btnSignUp").disabled = true; }
}

function resetForm(){
document.getElementById("btnSignUp").disabled = true;
var frmMain = document.forms[0];
frmMain.reset();
}

window.onload = function () {

var btnSignUp = document.getElementById("btnSignUp");
var btnReset = document.getElementById("btnReset");

var t1 = document.getElementById("t1");
var r1 = document.getElementById("r1");
var r2 = document.getElementById("r2");
var c1= document.getElementById("c1");
var email = document.getElementById("email");

var t1ck=false;
document.getElementById("btnSignUp").disabled = true;
email.onblur = formValidation;
t1.onkeyup = formValidation;
t2.onkeyup = formValidation;
r1.onclick = formValidation;
r2.onclick = formValidation;
c1.onclick = formValidation;
btnReset.onclick = resetForm;
}
</script>

 

form:

<form id="form2" name="form1" method="POST" action="">
   <table>
       <tr>
           <td>Email</td>
           <td><input type="text" name="email" id="email" />
               <div style= 'display: none' id ='slecht'><img src="Images/slecht.gif" border="0" alt="nok" /><span>dit is geen geldig UA email adres</span></div>
               <div id='goed' style='display: none'><img src="Images/goed.gif" border="0" alt="ok" /></div>
           </td>
       </tr>
       <tr>
           <td>Paswoord</td>
           <td><input type="password" id="t1" name="paswoord"></td>
       </tr>
       <tr>
           <td>Verifier paswoord</td>
           <td><input type="password" id="t2" name="paswoord2">
               <div id ='pwMatch'style='display: none; color:#C0C0C0'>Paswoord match!</div>
           </td>
       </tr>
       <tr>
           <td>Geslacht</td>
           <td><input type="radio" id="r1" name="gender" value=Male>Man <input type="radio" id="r2" name="gender" value=Female>Vrouw</td>
       </tr>
       <tr>
           <td>Terms & Condition</td>
           <td><input type=checkbox name=agree value=yes id=c1></td>
       </tr>
       <tr>
           <td align='right'><input type=reset id=btnReset value=Reset></td>
           <td><input type="submit" name="btnSignUp" id="btnSignUp" value="Sign Up!!" /> </td>
       </tr>
   </table>
</form>

Link to comment
https://forums.phpfreaks.com/topic/270081-problem-in-ie-with-following-js-code/
Share on other sites

i think the problem comes in the part where i want to unstyle the border for t1 and t2 textfields with:

 

else { document.getElementById("t1").style.border= "";

document.getElementById("t2").style.border= "";

 

the border of the textfield is removed in IE

Once again - you haven't said what the problem is. You want to unstyle a border? What does that mean? Remove it? Then you say the border is removed in IE? So what is the problem?

 

My solution: use jQuery. It's cross-browser compliant and much easier to use that this stuff.

 

As Jessica mentioned, jQuery makes DOM manipulation really easy, I would take a look into it. Although you could still save yourself some trouble without using it, by just adding/removing a class name instead of trying to change individual styles.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.