SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript works in IE and Opera but not Firefox!

    I have a login page that gets a .js file with validation code in it. In IE this code works fine, but FF it does not even run it.

    I have checked the console to see if there are any errors with the file and it says not, and i even tried putting the code back into the html file in script tag which did not work either.

    Any thoughts


    The code:
    Code:
    re = /^\w+([\.]?\w+)*@\w+([\.]?w=)*(\.\w{2,3})+$/
    	
    	//login form checkscript
    	function checkform(loginform){
        
            //Checks that an entry has be made
            if(loginform.username.value == ""){
                alert ("Please enter your email address")
            return false;
            }
            
            //Checks the format of the email
            if (re.test(loginform.username.value)){
                return true
                }
            
            //Checks the password field has an entry into
            if(loginform.password.value == ""){
                alert ("Please enter your password")
            return false;
            }
            
            //Alerts if email is entered incorrectly
            alert("You have entered an invalid email address, please re-enter")
            loginform.username.focus()
            loginform.username.select()
            return false;
            }
    Regards
    Graham

  2. #2
    SitePoint Addict Mirek Komárek's Avatar
    Join Date
    Dec 2006
    Location
    Prague
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    form onsubmit="checkform(this);return false"
    Normaly works for me in FF.

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I take my hat of to you, I have no idea why that works!!

    Is there a reason, or is it just somthing to be accepted?

    Thanks for that
    Graham


Bookmarks

Posting Permissions

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