Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Verifying password entry

Status
Not open for further replies.

Harshmellow

Programmer
Mar 28, 2002
18
BR
I need a script to verify if two entries are the same. I have textbox 1 which is for the password and textbox 2, for the password check. I generated the asp code with code charge, so if anyone know it, it would be better, but is not really necessary.

Thanks you all in advance,

HarshMEllow
 
The best way to do this would be to use client side javascript validation before your form is submitted. You could do something like the following

.
.
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

function validate(form)
{
if (form.pass1.value != form.pass2.value) {
alert(&quot;Your passwords do not match - please reenter!&quot;);
form.pass1.value = '';
form.pass2.value = '';
form.pass1.focus();
return false;
}
return true;
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME=&quot;myForm&quot; ACTION=&quot;myPage.asp&quot; METHOD=&quot;POST&quot; onSubmit=&quot;return validate(this)&quot;>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;pass1&quot;>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;pass2&quot;>
<INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Submit Form&quot;>
</FORM>
</BODY>
</HTML>

The code is very rough but you should get the general idea! Mighty :)
 
Thank you Mighty,

but I have some problem with were to put the code for it to work correctly. I don´t know if you know codecharge, but it saves two files, an asp onde, with the code, and a html template, which is where I suppose would go the javascript.
But, the problem that is, is that I can´t make ir work...

See the following:

<input type=&quot;hidden&quot; value=&quot;insert&quot; name=&quot;FormAction&quot;>
<input type=&quot;submit&quot; value=&quot;Cadastrar&quot; onclick=&quot;InserirDados.FormAction.value = 'insert';&quot; onSubmit=&quot;return validate(this)&quot;>


Is it correct to put an &quot;onSumit&quot; and an &quot;onClick&quot; events this way... I think this may be the problem...

thank you, .: HarshMellow :. &quot;Sperto ne estas tio, kio okazis al vi, sed estas tio, kion vi faras al tio, kio okazas al vi.&quot; (Aldous Huxley)
 
harshmellow,
are you saying that you don't have a form written on your page? example:

<FORM mothed='post' action='nextpage.asp'>
<input type=&quot;hidden&quot; value=&quot;insert&quot; name=&quot;FormAction&quot;>
<input type=&quot;submit&quot; value=&quot;Cadastrar&quot;>
</form>

If you have the form, then within the form declaration, put the onSubmit command:

<FORM mothed='post' action='nextpage.asp' onSubmit=&quot;return validate(this)&quot;>

that will call the validate() function which you will put in the &quot;head&quot; of your document:

<html>
<head>
<title>My Form Page</title>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

function validate(form)
{
if (form.pass1.value != form.pass2.value) {
alert(&quot;Your passwords do not match - please reenter!&quot;);
form.pass1.value = '';
form.pass2.value = '';
form.pass1.focus();
return false;
}
return true;
}
</SCRIPT>
</head>
<body>


Just as Mighty showed you. Perhaps I just mis-understand you though? -Ovatvvon :-Q
 
Thank you very much, it worked finally!

The problem was that I was not adding the onSubmit value to the proper location (the form tag), instead I was dumb enough to try and put this on the Insert/Send value field.

Thank you again!
.: HarshMellow :. &quot;Sperto ne estas tio, kio okazis al vi, sed estas tio, kion vi faras al tio, kio okazas al vi.&quot; (Aldous Huxley)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top