This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validate two passwords in struts

 
pingkan paula
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new to struts and assigned to web project using struts and ibatis.
I want to validate two input where user must put their new passwords twice, the validation used to check whether the two new password are the same.
Anyone has a clue from where i should start? do i have to use validator framework?
Any feedbacks will be fully appreciated
 
Junilu Lacar
Bartender
Pie
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not keep it simple and use the ActionForm validate() method. Another alternative is to use JavaScript.

Closing this here and moving to Struts.
 
Henry Lowell
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If using Struts 1.2.something (basically when they added validwhen) in the validation.xml for your form:

 
pingkan paula
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried using manual validation, but it returned NullPointerException errors, here is the validation code

 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure why you are calling super.validate twice. If posisi_password_baru1 is null, then your code will throw a NullPointerException. You may want to add a check in your code. If you have a "required" check in your xml validation, then you may want to bracket your custom validation code with an " if (errs.isEmpty())" check.

- Brent
 
jaisai vijay
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Henry Lowell,

I am using struts 1.2 and I have tried with the example you provide.

My code is like the following

I have three fields
currentpassword
newpassword
confirmpassword

Now I need to compare with new and confirpassword

I have written code like



I did not get any pop up when those two are not same. What would be the mistake in that?

Thanks for your help in advance.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic