Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Struts and javascript problem

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 17153
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic