1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

javascript + msie7

Discussion in 'JavaScript and AJAX' started by Ryzer, Mar 6, 2009.

  1. Ryzer

    Ryzer New Member

    Joined:
    Feb 15, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Pipeline Maintenance
    Location:
    Saskatchewan, Canada
    a register page that i've created works great in firefox, but in ie7 for some reason it doesnt want to load/update the javascript. i've got a password strength checker which updates after a key is entered into the password field. same thing with the country/state dropdown. both work in firefox, and neither work in ie7. any ideas?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    unless you share what is not working for you there can be million of things which can work in one and not in other
     
  3. Ryzer

    Ryzer New Member

    Joined:
    Feb 15, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Pipeline Maintenance
    Location:
    Saskatchewan, Canada
    here is the code for password strength

    in register.php
    Code:
    include 'functions.php';
    
    ..
    
    
    <tr> <td align="right">Password:</td> <td> <input type="password" name="password" maxlength="30" style="width: 250" onkeyup="passwordStrength(this.value);"> </td> <td>*</td> </tr>
    
    ...
    
    //displays the actual password strength realtime after each key is entered in password field
    <table width="16%" align="left">
    	<tr><label for="passwordStrength">Password strength</label>
    		<div id="passwordDescription">Password not entered</div>
    		<div id="passwordStrength" class="strength0"></div></tr>
    </table>
    
    ..
    
    
    in functions.php
    Code:
    <html>
    <body>
    
    <script type="text/javascript">
    function passwordStrength(password)
    {
    	var desc = new Array();
    	desc[0] = "Very Weak";
    	desc[1] = "Weak";
    	desc[2] = "Better";
    	desc[3] = "Medium";
    	desc[4] = "Strong";
    	desc[5] = "Strongest";
    
    	var score   = 0;
    
    	//if password bigger than 6 give 1 point
    	if (password.length > 6) score++;
    
    	//if password has both lower and uppercase characters give 1 point	
    	if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;
    
    	//if password has at least one number give 1 point
    	if (password.match(/\d+/)) score++;
    
    	//if password has at least one special caracther give 1 point
    	if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) )	score++;
    
    	//if password bigger than 12 give another 1 point
    	if (password.length > 12) score++;
    
    	 document.getElementById("passwordDescription").innerHTML = desc[score];
    	 document.getElementById("passwordStrength").className = "strength" + score;
    }
    </script>
    </body>
    </html>
    
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    I see some browsers have the syntax of

    <script type="text/javascript">

    as

    <script type="text/javascript">
    <!--

    and that could be one reason as well
     
  5. Ryzer

    Ryzer New Member

    Joined:
    Feb 15, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Pipeline Maintenance
    Location:
    Saskatchewan, Canada
    doesnt seem to have any effect. i also tried removing the html and body tags. javascript does not need to be in a .js file am i correct? although i may try this way to see if it works
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    No it can be inline as well as in JS File
     
  7. Ryzer

    Ryzer New Member

    Joined:
    Feb 15, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Pipeline Maintenance
    Location:
    Saskatchewan, Canada
    I figured out the solution to this problem. I had <script ...> and </script> at start and end of the function file but i needed to close the script tag at the end of the first function, and start it again after for the next function.

    Code:
    <script type="text/javascript">
    
    function 1(){
      //stuff here
    }
    
    </script>
    
    <script type="text/javascript">
    
    function 2(){
      //stuff here also
    }
    
    </script>
    
     
  8. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    IE rocks for this kind of bluff only
     
  9. Ryzer

    Ryzer New Member

    Joined:
    Feb 15, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Pipeline Maintenance
    Location:
    Saskatchewan, Canada
    :thinking: i've been told we cannot force people to use certain browsers, but i disagree :hammer:
     

Share This Page