• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts and javascript problem

 
Krishna Mohan V
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am developing a web application using tomcat 5.0.30 , struts and backend as iBatis framework.
Becuase of being JSTL as new to me , I went for javascript.
and
In the main form, I have two fields for Username and Password.

Because I am not using validations using struts, in my struts-config.xml,I have set validate="false", line beginning with input was removed.

I have written javscript, which is taking care of these validations.

The problem is , if I enter a value for username, not for password,
javascript is displaying "Password is mandatory", but when I click "OK" button,

username and password are showing blank.

The requirement is it should retain the value entered by me in username field.

Can any of you help me please?

Although this may look simple, but in my next screens , I have nearly 25 Textboxes and I dont want all these field values being set to blank, if a alert message comes up.

Thanks in advance,
Krishna.
 
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
Please post your JavaScript code so we can have a better idea of what's happening. Also, JavaScript validation should be used as a front-line defense only. You have no control over the client browsers and they could easily have JavaScript turned off. Don't rely on the JavaScript validation; you should also validate on the server-side to ensure that the data processed is valid.
 
Sham Grandhe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Krishna Mohan,
I think the problem is simple, even if the form is being validated by javascript, the data will move to the ActionForm bean, hence try with the request parameter method. hope this could help you.

<html:text property="username" value="<%= request.getParameter("username")==null?"":request.getParameter("username")%>" />

sham
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic