The moose likes Struts and the fly likes validate two passwords in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validate two passwords in struts" Watch "validate two passwords in struts" New topic

validate two passwords in struts

pingkan paula
Ranch Hand

Joined: Sep 03, 2004
Posts: 117
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

Joined: Feb 26, 2001
Posts: 6496

Why not keep it simple and use the ActionForm validate() method. Another alternative is to use JavaScript.

Closing this here and moving to Struts.

Junilu - [How to Ask Questions] [How to Answer Questions]
Henry Lowell
Ranch Hand

Joined: May 29, 2006
Posts: 63
If using Struts 1.2.something (basically when they added validwhen) in the validation.xml for your form:

pingkan paula
Ranch Hand

Joined: Sep 03, 2004
Posts: 117
I've tried using manual validation, but it returned NullPointerException errors, here is the validation code

Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
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

Joined: Dec 17, 2009
Posts: 70
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

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.
I agree. Here's the link:
subject: validate two passwords in struts
jQuery in Action, 3rd edition