...

View Full Version : Form Field Value and Type change not functioning in mac browsers



beccalouwho
07-01-2004, 04:26 PM
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>

beccalouwho
07-01-2004, 09:09 PM
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.

Willy Duitt
07-01-2004, 09:28 PM
I remember writing that script but I do not have a MAC to test on.
I suppose, Safarie does not support the DOM createElement()..... :confused:

.....Willy

beccalouwho
07-02-2004, 02:08 PM
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!

glenngv
07-05-2004, 06:14 AM
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 (http://www.codingforums.com/showthread.php?p=178016#post178016)

beccalouwho
07-06-2004, 01:52 PM
yep, its turned on... and I'm not seeing any errors



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum