onclick functions not working in Internet Explorer and Firefox

I am trying to make a mobile app that is cross browser compatible. Everything is fine but when it comes to onClick javascript function it does not work in IE or even in Firefox. I would really appreciate if someone can help me with it. Here is a fiddle

html

    <div class="main"> <div class="navigate" role="navigation">
     <nav> <ul>   <li class="brave"><a href="#home"> UX App</a></li>   <li class="menu" id="parentmenu"><a href="#about" id="mainmenu">Menu<span class="box-shadow-menu"></span></a>


  <ul class="sub closed" id="sub">
            <li><a href="#">Dashboard></a></li>
            <li><a href="#">My Profile</a></li>
            <li><a href="#">Settings</a></li>
            <li><a href="#">Help</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Logout</a></li>
    </ul>
    </li>
    </ul> </nav> </div><!--navigate--> <div class="center"> <img src="icon.png" id="icon"> <p id="bookmark">Do NOT bookmark this page</p> <p id="sig"><b>Sign Up</b></p> <div class="form">
    <form name="signup" class="signup">
        <input type="text" placeholder="Username" id="uname" />
        <input type="password" placeholder="Password" id="pwd" class="masked" />
        <button type="submit" onclick="show()" id="eye">
            <img src="eye.png" alt="eye"/>
         </button>
        <button id="btn" onclick="validate()">SignUp</button> <span class="help">Need Help?</span>
    </form> </div><!--form-->

</div><!--center--> <div class="ebanner" id="banner">
     </div> <div class="bottom">
    <div id="bottom-content">Powered by Brave UX</div> </div><!--bottom--> </div><!--main-->

js

      function validate()
    {
        var username= document.getElementById("uname").value;
        var str = document.getElementById("pwd").value;
        if (uname=="hi" && password =="wassup") 
        {
            alert("login Successfully");
        }
        else if(username.length==0)
        {
            document.getElementById("banner").style.display="block";
            document.getElementById('banner').innerHTML="Username is required";
            document.getElementById("uname").style.borderColor="red";
            username.focus();
        }

        else if (str.length < 6) 
            {
                 document.getElementById("banner").style.display="block";
                 document.getElementById('banner').innerHTML="Password length should be atleast 6";
                 document.getElementById("pwd").style.borderColor="red";

            } 

        else if (str.search(/d/) == -1)
         {
         document.getElementById("banner").style.display="block";
                 document.getElementById('banner').innerHTML="Password should contain a numeric value";
                 document.getElementById("pwd").style.borderColor="red";
        } 
        else if (str.search(/[A-Z]/) == -1)
         {
        document.getElementById("banner").style.display="block";
                 document.getElementById('banner').innerHTML="Password should contain atleast one Capital letter";
                 document.getElementById("pwd").style.borderColor="red";
        } 

    else if (str.search(/[^a-zA-Z0-9!@#$%^&*()_+.,;:]/) != -1)
     {
        document.getElementById("banner").style.display="block";
                 document.getElementById('banner').innerHTML="Irrelevant character found";
                 document.getElementById("pwd").style.borderColor="red";
    }

    }
<!--menu display function-->
    function menuToggle()
    {
    var menubtn = document.getElementById('mainmenu');
    var sub = document.getElementById('sub');
    if(menubtn)
    {
    menubtn.addEventListener('click', function () {
    var closed = sub.className.indexOf('closed') !== -1;
    if (closed) 
    {
        sub.className = sub.className.replace('closed', 'open');
    } else 
    {
        sub.className = sub.className.replace('open', 'closed');
    }
        });
    }
}


Source: cross-browser

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.