SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot Defiant's Avatar
    Join Date
    Feb 2006
    Location
    Durham, UK
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need a bit help here.

    K im realtivly new to js and I cant figure this issue out.

    I have this script for checking to see if all the fields of a registration form have been completed and checks to see if the passwords match before showing the add user button.

    Code:
    <script language="javascript">
    function checkComplete (fn, sn, p1, p2)
    {
    	fn1 = document.getElementById ( fn ) .value;
    	sn1 = document.getElementById ( sn ) .value;
    	pass1 = document.getElementById ( p1 ) .value;
    	pass2 = document.getElementById ( p2 ) .value;
    
    	if ( fn1 != '' && sn1 != '' && pass1 != '' && pass2 != '' ){
    		if(pass1 != pass2){
    			document.getElementById ('status') .innerHTML = '<p class="error">Passwords does not match</p>';
    		} else {
    			document.getElementById ('status') .innerHTML = '<p><input type="submit" value="Register"></p>';
    		}
    	} else {
    		document.getElementById ('status') .innerHTML = '<p class="error">Complete All Fields</p>';
    	}
    }
    </script>
    This script then outputs either a message of displays the add user button in this div:

    Code:
    <span id="status"></span>
    The script works fine in FF but IE wont have it.

    It retuns errors involving these bits:
    • document.getElementById ('status') .innerHTML = '<p class="error">Passwords does not match</p>';
    • document.getElementById ('status') .innerHTML = '<p><input type="submit" value="Register"></p>';
    • document.getElementById ('status') .innerHTML = '<p class="error">Complete All Fields</p>';


    I would appreciate it if someone could point out where the issue is. Im new to JS and its still one huge blur to me.

    Thanks in advance.
    Webdesigner in Training
    Currently Studying: PHP

  2. #2
    SitePoint Addict ALL's Avatar
    Join Date
    Oct 2005
    Location
    South Dakota
    Posts
    215
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    well not sure what to say... because it all looks good to me... however... if you give us a runable page i can debug the javascript for you to figure it out.

    Other than that... if you named an element "status" it might have a conflict with IE, because IE5 and IE6 both have a problem with returning elements with the name you are requesting...

    but they fixed that in IE7 (atleast that is according to http://www.quirksmode.org/dom/w3c_core.html).

    just give us a runable version and we can help you much more,
    -ALL
    Did I help you?
    You can repay me, support one of my projects (no money needed):
    JavaScript Wiki, Another Web Forum, Paranormal Site

  3. #3
    SitePoint Guru Rob_D's Avatar
    Join Date
    Oct 2006
    Location
    UK
    Posts
    882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it OK to have spaces in the code?
    Code:
    document.getElementById ('status') .innerHTML
    should be
    Code:
    document.getElementById('status').innerHTML
    Maybe?


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
  •