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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

matching two password textboxes

Status
Not open for further replies.

critical5

Programmer
Dec 13, 2006
37
GB
Hi there, I am having a problem validating user input. When a user is registering, i need them to create a password and confirm it using another textbox field and then submit it to the database. I have created the form and submits correctly but need to match the two password strings entered on the form...Does anybody have any suggestions? tried googling it but nothing relevant!

Thanks for your help
 
Code:
<cfif Form.Password1 EQ Form.Password2>

Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
Hi there,

this is almost working but it is only checking if password box 2 contains something...if i type anything else it allows it...below is my code:

<cfhtmlhead text="<title>#variables.SiteName#</title>">
<cfif #Form.user_password# eq #Form.user_password_retry#>
<cfelseif isdefined("form.user_email")>
<cfquery name="CheckReg" datasource="#request.dsn#">
SELECT user_email
FROM users
WHERE user_email = '#form.user_email#'
</cfquery>

<cfif CheckReg.recordcount gte 1>
<cfoutput>
The email address is already registered. You login here.
</cfoutput>
<cfelse>


....query

Am i doing anything wrong?
 
i would do this with a javascript function instead. something like :

function checkPassword()
{
if (document.forms[0].Password1.value.length < 6 )
{
alert("Password must be at least 6 characters long!");
document.forms[0].Password1.focus();
return false;
}
else if (document.forms[0].Password2.value != document.forms[0].Password1.value)
{
alert("Passwords do not match! Please re-enter the password.");
document.form[0].Password2.focus();
return false;
}
else
{
return true;
}
}


and then you will add an onClick event to the submit button to run the validation:

<input type="submit" .... onclick="return checkPassword();">

hope it helps.

 
Server side vs. client side. You need both - at least on a public site.

Critical5 - maybe this will help:

<cfif Form.Password1 NEQ Form.Password2 OR LEN(FORM.Password1) EQ 0>
Some action here - maybe redirect to an error page or set an error flag

<CFELSE>
Continue with your processing.

</CFIF>




Cheers,

Bluetone
 
I always do a double validation. A JS based whenever possible (like form validation, scrub bad words, minimum char count, etc) and then the same validation sever level. Just in case for users that don't have JS enabled, or turned off, or inconsistancy of browser verions...

____________________________________
Just Imagine.
 
I also always do server side validation, which is why I rarely use JS for it. I also like to send back a structure of fieldname/value and fieldname/error message so the errors are very clear to the user, fields highlighted, etc.

form validation is one of those things that I think everyone does differently, but I like to see how everyone does it.

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
In spite of my earlier post I agree with imstillatwowrk - I have been leaving off client side validation lately and building user friendly server side validation and error messages - at least on public sites. I have a large intranet that uses JS only. I can get away with it because the environment is homogeneous and controlled.

Cheers,

Bluetone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top