Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

radio button and ValidateAndSubmit problem  RSS feed

 
Jay jie
Greenhorn
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?
 
Stefan Evans
Bartender
Posts: 1834
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
Greenhorn
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!!!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"eric gs", please check your private messages for an important administrative matter. Again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!