wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts and javascript  problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts and javascript  problem" Watch "Struts and javascript  problem" New topic
Author

Struts and javascript problem

Krishna Mohan V
Greenhorn

Joined: Mar 16, 2004
Posts: 20
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

Joined: Feb 26, 2001
Posts: 4444
    
    5

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.


Junilu - [How to Ask Questions] [How to Answer Questions]
Sham Grandhe
Ranch Hand

Joined: Dec 16, 2003
Posts: 73
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts and javascript problem
 
Similar Threads
Spring MVC commons-validator - Over riding default messages
Validations using ActionErros Validate
struts 1.3,Validator forpassword field
focusControl has no properties
Struts 2.1.8 validation.xml & internationalization