This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line!
See this thread for details.
Win a flower (🌹) or copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java (📚) 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
master stewards:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
garden masters:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
gardeners:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

radio button and ValidateAndSubmit problem

 
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I got some problem about this task hope who know can help me!!!thanks 1st!!
SINGLE


MULTIPLE
















i use the following code to identifier when select single radio then display it content else is multiple content

so my problem is in the Validate And Submit
it validate account Number, cheque Number,cheque Number From,cheque Number To and reason.
But the thing different between single and double is when i click single it display cheqye Number,else display cheque Number From and cheque Number To!!
so when i click single it suppose validate cheque Number only but it prompt out need fill in cheque Number From and cheque Number To .
so anyone can help me?
 
gardener
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe one reason that nobody has responded as yet, is that this is some truly horrible code to understand.

That whole msg* thing you have going is hard to understand.
When you call the validate method with seemingly random permutations of them, that just screams to me of trouble waiting to happen.

And then you go mixing scriptlet code with your javascript code...

However, on a bit of a closer look, the problem can be nutted down to this:


Java != javascript
If you think about the JSP lifecycle, the java code executes, outputs an HTML page, and stops running.
Then javascript executes on your page.

View source on your generated HTML, and take a look at the validate method. Does it show what you want it to?
Here is one of the pitfalls of mixing java and javascript code on the page.

Depending on what the java methods show() and chequeBean.isStatus() return will determine which bit of javascript validation code appears on your page.
It will either produce the validation code for a single field. Or for the two fields.

However, your page is dynamically changing which fields are shown via javascript.
So you are making the decision about which bit of validation code to run too early - in the java rather than the javascript.

Get rid of the scriptlet code, and write this as purely javascript.
if should be something like



Plus don't forget to validate this stuff on the server side as well :-)
 
Jay jie
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry make you inconvenient about reading this code.
Actually my question is if select single it need validate single field else validate double field.
So how can i get the single Radio Button Selected and validate Single Field .Validate Single Field is put in the script? But i am using function show and hide!!!
 
Marshal
Posts: 67357
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"eric gs", please check your private messages for an important administrative matter. Again.
 
I've got no option but to sell you all for scientific experiments. Or a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!