Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Form Field Value and Type change not functioning in mac browsers

    the form is a user name and password login.
    the fields both begin with a value (USER ID) and (PASSWORD) and should switch to whatever value the user enters (this doesn't happen for password in Safari)
    the fields also begin grey and turn black when clicked ( this doesn't work in Safari)

    The problem is on the mac platform (everything works fine on pc)
    In Safari, the password field keeps its initial PASSWORD value.
    and in IE on Mac the field doesn't change color, or type(****)

    I'm not as worried about the IE problem as I am about the Safari problem
    I hope that was all clear.

    now here is the code:
    <script language="JavaScript" type="text/javascript">
    <!--

    function changeType(input){
    if(input.value == 'PASSWORD'){
    txtPassword = document.createElement('input');
    txtPassword.name = 'txtPassword';
    txtPassword.type = 'password';
    input.parentNode.insertBefore(txtPassword,input);
    input.parentNode.removeChild(input);
    txtPassword.size='12.5';
    txtPassword.focus();
    txtPassword.style.color='black';
    } else {
    txtPassword.select();
    }
    }

    function validateFields (formObj){
    // size of form is currently 2 items any additions need to be accounted for
    if(document.collection_order.txtLogin.value == "")
    {
    alert ('The following field is empty: "User ID"');
    document.collection_order.txtLogin.focus();
    return false;
    }

    if(document.collection_order.txtPassword2.value == "" && (document.collection_order.txtLogin.value.indexOf('@') < 0 || document.collection_order.txtLogin.value.indexOf('.') < 0))
    {
    alert ('The following field is empty: "Password"');
    document.collection_order.txtPassword2.focus();
    return false;
    }
    }

    function FormSubmit2(){
    if(document.collection_order.txtLogin.value == "")
    {
    alert ("Please enter your primary email into the User ID!");
    document.collection_order.txtLogin.focus();
    return false;
    }else{
    document.collection_order.submit();
    }
    }

    function FormSubmit(){
    document.collection_order.submit();
    }

    //-->
    </script>
    </head>


    <body>
    <form action="http://hq.ssrn.com/Pub_Login.cfm?function=Login"
    method="post"
    target="_top"
    onsubmit="return validateFields('document.collection_order.elements')"
    name="collection_order"
    >

    <br/>

    <input
    style="color: #999; height: 20px; font-size: 12px;"
    value="PASSWORD"
    name ="txtPassword"
    size="12"
    onclick="changeType(this)"
    onfocus="this.style.color='black';"
    />


    <input
    name="Process"
    type="submit"
    value="Go"
    />
    </form>
    </body>
    </html>

  • #2
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I should clarify...

    the exact problem in Safari is that when the form is submitted, the password field retains the value of 'password' which was initially set instead of changing to whatever the user types in.


    This shouldn't happen and doesn't happen for any of the other browsers.

    Also, if i take out the code which replaces the text field with a password field

    function changeType(input){
    if(input.type == 'text'){
    txtPassword2 = document.createElement('input');
    txtPassword2.name = 'txtPassword2'
    txtPassword2.type='password';
    input.parentNode.insertBefore(txtPassword2,input);
    input.parentNode.removeChild(input);
    txtPassword2.value='';
    txtPassword2.size='12.5';
    txtPassword2.focus();
    txtPassword2.style.color='black';

    thus leaving the password field a text field, the form submits properly.

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I remember writing that script but I do not have a MAC to test on.
    I suppose, Safarie does not support the DOM createElement().....

    .....Willy

  • #4
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was afraid it would be something like that... I've certainly exhausted every other possibility. unfortunately, info on Safari is hard to find.

    and yes, your script from before was very helpful - I was almost at the giving up point, since I didn't have enough knowledge of DOM to do it without an example.



    thanks for the feedback though these forums are ever so educational
    musch appreciated!
    Last edited by beccalouwho; 07-02-2004 at 02:35 PM.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Is the hidden Debug menu turned on? Although Safari produces unhelpful error messages, it's better than nothing. You can see how to enable it in the last part of this post
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yep, its turned on... and I'm not seeing any errors


  •  

    Posting Permissions

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