permaculture playing cards*
The moose likes Servlets and the fly likes Checking value of one textfield matching the other Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Checking value of one textfield matching the other" Watch "Checking value of one textfield matching the other" New topic
Author

Checking value of one textfield matching the other

vanan saravanan
Ranch Hand

Joined: Jun 02, 2006
Posts: 95
I'm trying to come up with a password change function. This is how it should work

1 textfield : enter new passowrd
2 textfield : enter same password

If the value from both the textfield match, then update the database. I do know how to do the updating and retriving part. Need help on how to compare both textfields and to provide a pop up if they dont match.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by vanan saravanan:
I'm trying to come up with a password change function. This is how it should work

1 textfield : enter new passowrd
2 textfield : enter same password

If the value from both the textfield match, then update the database. I do know how to do the updating and retriving part. Need help on how to compare both textfields and to provide a pop up if they dont match.


I think, Javascript would be better for this kind of validation but do it on server side also.

Getting value of textfield in JS:
var value = document.getElementById("id_of_textfield").value;

Now it's your job.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

The general guideline is, always use javascript to validate really simple logic but also always validate any input to the middle tier. This may mean validation gets checked at 3 levels (javascript/servlet/database) but its not pointless since your inputs may not come from the same places all the time and the systems need to protect themselves and their data.


My Blog: Down Home Country Coding with Scott Selikoff
Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
Hello,

Scott, what do you meen by servlet validation?

Cheers
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Marko Debac:
Hello,

Scott, what do you meen by servlet validation?

Cheers


What he means is that it's important to validate input on the servers side (even if you're also doing so with Javascript on the client).


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Checking value of one textfield matching the other
 
Similar Threads
authenticating/validating user name and password
Integers and Textfields.
calling a class
numeric textfield
how to match two textfields data using validator framework