Results 1 to 3 of 3

Thread: Javascript code help

Hybrid View

  1. #1
    Join Date
    Mar 2012

    Question Javascript code help

    Code below is not working...nothing happens on clicking submit...javascript is enabled in browser..help please.

    <script type="text/javascript">
    function match()
    var aa=document.getElementById("username").Value;
    var bb=document.getElementById("password").Value;
    if(aa==null || bb==null)
    alert("Enter Again");
    else if((aa=="admin") && (bb=="12345"))
    Alert("Hello Sir");
    else if((aa=="guest") && (bb=="67890"))
    Alert("Hello Guest");
    Alert("Enter Valid Info");
    Username:<input type="text" id="username"/><br/>
    Password:<input type="text" id="password"/><br/>
    <input type="submit" onClick="match()"/>

  2. #2
    Join Date
    May 2004
    chennai, tamil nadu, India
    Alert should be alert
    Chris, Senior Developer, Chrisranjana.com
    Php Programmers

  3. #3
    Join Date
    Mar 2012
    Also, you should avoid placing your curlybraces on the line after your parenthesis(). Some say its a matter of preference but it can matter in certain circumstances. A bad habit to start early on. Proper syntax is :
    function myFunction() {
      var myVariable = "Welcome";
    I would also avoid the use of non-descriptive variables such as "aa" or "bb". Use something that describes what the variable holds without being too lengthy. There is nothing wrong with username or password as variable names. Again, being picky but its a bad habit to start early on.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles