JS not working in Mozila
-
Hi all, Im checking the password strength using JS. It works fine in IE but not in Mozila . Can any one solve my problem please. Here is the script.
<script language="javascript" type ="text/javascript">
function check_password_safety(pwd)
{
var msg = "";
var len= pwd.length;
var i;var has\_letter = new RegExp("\[a-z\]"); var has\_caps = new RegExp("\[A-Z\]"); var has\_numbers = new RegExp("\[0-9\]"); var has\_symbols = new RegExp("\\\\W"); var pointsLetter=0; var pointsCaps=0; var pointsNumbers=0; var pointsSpecials=0; for(i=0;i<len;i++) { var x=pwd.charAt(i); if(has\_letter.test(x)) { ++pointsLetter; } else if(has\_caps.test(x)) { ++pointsCaps; } else if(has\_numbers.test(x)) { ++pointsNumbers; } else if(has\_symbols.test(x)) { ++pointsSpecials; } } // alert('Small Letters = '+pointsLetter+'\\nSmall Caps = '+pointsCaps+'\\nSmall Numbers = '+pointsNumbers+'\\nSmall Specials = '+pointsSpecials); if(len>6) { // Small + Abvove 12 Char if(pointsLetter>0 && pointsCaps==0 && pointsNumbers==0 && pointsSpecials==0 && len>12) { password\_info.innerHTML = "Very Week"; password\_info.className='Style\_VeryWeek'; } // Small if(pointsLetter>0 && pointsCaps==0 && pointsNumbers==0 && pointsSpecials==0 && len<12) { password\_info.innerHTML = "Week"; password\_info.className='Style\_Week'; }
-
Hi all, Im checking the password strength using JS. It works fine in IE but not in Mozila . Can any one solve my problem please. Here is the script.
<script language="javascript" type ="text/javascript">
function check_password_safety(pwd)
{
var msg = "";
var len= pwd.length;
var i;var has\_letter = new RegExp("\[a-z\]"); var has\_caps = new RegExp("\[A-Z\]"); var has\_numbers = new RegExp("\[0-9\]"); var has\_symbols = new RegExp("\\\\W"); var pointsLetter=0; var pointsCaps=0; var pointsNumbers=0; var pointsSpecials=0; for(i=0;i<len;i++) { var x=pwd.charAt(i); if(has\_letter.test(x)) { ++pointsLetter; } else if(has\_caps.test(x)) { ++pointsCaps; } else if(has\_numbers.test(x)) { ++pointsNumbers; } else if(has\_symbols.test(x)) { ++pointsSpecials; } } // alert('Small Letters = '+pointsLetter+'\\nSmall Caps = '+pointsCaps+'\\nSmall Numbers = '+pointsNumbers+'\\nSmall Specials = '+pointsSpecials); if(len>6) { // Small + Abvove 12 Char if(pointsLetter>0 && pointsCaps==0 && pointsNumbers==0 && pointsSpecials==0 && len>12) { password\_info.innerHTML = "Very Week"; password\_info.className='Style\_VeryWeek'; } // Small if(pointsLetter>0 && pointsCaps==0 && pointsNumbers==0 && pointsSpecials==0 && len<12) { password\_info.innerHTML = "Week"; password\_info.className='Style\_Week'; }
if i am not wrong!!!!! some of the script will not work in Mozila..... :omg: :omg:
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
Hi all, Im checking the password strength using JS. It works fine in IE but not in Mozila . Can any one solve my problem please. Here is the script.
<script language="javascript" type ="text/javascript">
function check_password_safety(pwd)
{
var msg = "";
var len= pwd.length;
var i;var has\_letter = new RegExp("\[a-z\]"); var has\_caps = new RegExp("\[A-Z\]"); var has\_numbers = new RegExp("\[0-9\]"); var has\_symbols = new RegExp("\\\\W"); var pointsLetter=0; var pointsCaps=0; var pointsNumbers=0; var pointsSpecials=0; for(i=0;i<len;i++) { var x=pwd.charAt(i); if(has\_letter.test(x)) { ++pointsLetter; } else if(has\_caps.test(x)) { ++pointsCaps; } else if(has\_numbers.test(x)) { ++pointsNumbers; } else if(has\_symbols.test(x)) { ++pointsSpecials; } } // alert('Small Letters = '+pointsLetter+'\\nSmall Caps = '+pointsCaps+'\\nSmall Numbers = '+pointsNumbers+'\\nSmall Specials = '+pointsSpecials); if(len>6) { // Small + Abvove 12 Char if(pointsLetter>0 && pointsCaps==0 && pointsNumbers==0 && pointsSpecials==0 && len>12) { password\_info.innerHTML = "Very Week"; password\_info.className='Style\_VeryWeek'; } // Small if(pointsLetter>0 && pointsCaps==0 && pointsNumbers==0 && pointsSpecials==0 && len<12) { password\_info.innerHTML = "Week"; password\_info.className='Style\_Week'; }
First try to find out with the help of Alert() that which line of code is not working so can easily help you.
Parwej Ahamad http://parwej.wordpress.com/
-
Hi all, Im checking the password strength using JS. It works fine in IE but not in Mozila . Can any one solve my problem please. Here is the script.
<script language="javascript" type ="text/javascript">
function check_password_safety(pwd)
{
var msg = "";
var len= pwd.length;
var i;var has\_letter = new RegExp("\[a-z\]"); var has\_caps = new RegExp("\[A-Z\]"); var has\_numbers = new RegExp("\[0-9\]"); var has\_symbols = new RegExp("\\\\W"); var pointsLetter=0; var pointsCaps=0; var pointsNumbers=0; var pointsSpecials=0; for(i=0;i<len;i++) { var x=pwd.charAt(i); if(has\_letter.test(x)) { ++pointsLetter; } else if(has\_caps.test(x)) { ++pointsCaps; } else if(has\_numbers.test(x)) { ++pointsNumbers; } else if(has\_symbols.test(x)) { ++pointsSpecials; } } // alert('Small Letters = '+pointsLetter+'\\nSmall Caps = '+pointsCaps+'\\nSmall Numbers = '+pointsNumbers+'\\nSmall Specials = '+pointsSpecials); if(len>6) { // Small + Abvove 12 Char if(pointsLetter>0 && pointsCaps==0 && pointsNumbers==0 && pointsSpecials==0 && len>12) { password\_info.innerHTML = "Very Week"; password\_info.className='Style\_VeryWeek'; } // Small if(pointsLetter>0 && pointsCaps==0 && pointsNumbers==0 && pointsSpecials==0 && len<12) { password\_info.innerHTML = "Week"; password\_info.className='Style\_Week'; }
there is nothing written wrong in the code. The only thing that comes into my notice is
password_info.innerHTML
Always remove the existing childelements before you set the innerHTML, so that if there is any child elements present, IE will throw an error. Use like this :
function setContent(container, content) {
if (!!container) {
while (container.firstChild)
container.removeChild(container.firstChild);var dummyDiv = document.createElement('div'); dummyDiv.innerHTML = content; container.appendChild(dummyDiv); } }
Now call
setContent(password_info,"yourhtml")
On your problem, I think there must be problem somewhere else. Check Mozilla Error Console for that entry. :thumbsup:Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.