RE : validate 2 password fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry, my typo, the else line should have read (note the missing brace)

                return true;
        } else {
        alert("Passwords did not match");

Please note you need to turn on error reporting for scripts in IE or your chosen browser - doing so would have told you the line which had the syntax error. Developing websites with error reporting turned off is a terribly bad idea ;-)

Cheers - Neil

At 23:11 29/06/2004 -0400, Vincent Jordan wrote:
I have the following code and it is not working. it will pass the info
along. hwew is a copy of the entire code:.

<?php ?>
<script>
function Validate()
{
if (document.UserAddNew.username.value == '')
{
alert('Warranty Database:\nPlease Enter a Username\!');
document.UserAddNew.username.select();
return false;

}
if (document.UserAddNew.password.value == '')
{
alert('Warranty Database:\nPlease Enter a Password\!');
document.UserAddNew.password.select();
return false;
}
}

function checkpasswords() {
df=document.forms['UserAddNew'];
if (df['password'].value==df['password2'].value) {
// Passwords matched, clear password2, allow form to submit
df['password2'].value='';
return true;
else {
alert('Passwords did not match');
return false;
}
}

</script>


<form method='post' action='' name='UserAddNew' onSubmit='return checkpasswords()'> Username : <INPUT TYPE='TEXT' name='username' title='username' id='username'><br> Password : <INPUT TYPE='TEXT' name='password' title='password' id='password'><br> Re Type Password: <INPUT TYPE='TEXT' name='password2' title='password2' id='password2'><br> Department: <SELECT name='department' title='department' id='department'> <OPTION value='Managment'>Managment</OPTION> <OPTION value='Sales'>Sales</OPTION> <OPTION value='Tech Support'>Tech Support</OPTION> <OPTION value='Returns'>Returns</OPTION> <OPTION value='Other'>Other</OPTION></SELECT><br> <input type=submit name=submit value='Add'> <input type=reset name=reset value='Reset' onClick="if (confirm('Warranty Database:\nAre you sure you want to reset the form\?'));"> </FORM>

----- Original Message -----
From: "Neil Smith [MVP, Digital media]" <php@xxxxxxxxxxxxxxxxxxxxxxxx>
To: <vjordan@xxxxxxxxxxxxxxx>
Cc: <php-db@xxxxxxxxxxxxx>
Sent: Tuesday, June 29, 2004 6:25 AM
Subject: [SPAM] RE : validate 2 password fields


> Attach onsubmit="return checkpasswords()" to your form tag..... > > function checkpasswords() { > df=document.forms["DisplayUser"]; > if (df["password1"].value==df["password2"].value) { > // Passwords matched, clear password2, allow form to submit > df["password2"].value=""; > return true; > else { > alert("Passwords did not match"); > return false; > } > } > > Cheers - Neil > > > > > >Message-ID: <002c01c45ca9$cffcdbe0$fe00000a@extendeddwc7l0> > >From: "Vincent Jordan" <vjordan@xxxxxxxxxxxxxxx> > >To: <php-db@xxxxxxxxxxxxx> > >Date: Sun, 27 Jun 2004 20:49:47 -0400 > >MIME-Version: 1.0 > >Content-Type: multipart/alternative; > > boundary="----=_NextPart_000_0029_01C45C88.48576050" > >Subject: 2 requests: validate 2 password fields as equal and rewrite data > > > >Could someone instruct me or point me in the right direction. I would like > >to have a <input type=password name=password> <input type=password > >name=password2> when submit it will check to se if password and password2 > >are = ( i do not want password2 to end up in POST on submit.) > > > ======================================================== > CaptionKit http://www.captionkit.com : Production tools > for accessible subtitled internet media, transcripts > and searchable video. Supports Real Player, Quicktime > and Windows Media Player. > > VideoChat with friends online, get Freshly Toasted every > day at http://www.fresh-toast.net : NetMeeting solutions > for a connected world. > > > >


========================================================
CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux