• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checking value of one textfield matching the other

 
vanan saravanan
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Saloon Keeper
Posts: 4028
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marko Debac
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Scott, what do you meen by servlet validation?

Cheers
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic