my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes unable to do validation for select in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "unable to do validation for select in struts2" Watch "unable to do validation for select in struts2" New topic
Author

unable to do validation for select in struts2

madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi,
im new to struts2..in my application i need to use that Struts2 concept..im developing jsp page..i had designed..drop-down box in jsp..if im doing validation it is not getting..and it is not getting validated..can any one help me out..
login.jsp

login.js

thanks in advance,
madhu.
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
any help regarding my post
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Waiting an hour is not showing enough patience: PatienceIsAVirtue.

Also, when posting in the HTML/JavaScript forum, please show only the rendered HTML--JSP is useless to us. You may find that looking at the rendered HTML is enough to solve your problem. Plus your JavaScript is wrong anyway, unless you really want a user to be able to select the header label as a legal value.
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
ok..here is my coding
login.jsp

login.js

any help why it is not validating
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I think you misunderstood what I meant when I said "post the rendered HTML". You just posted more *more* JSP, which is kind of the opposite of what is useful.
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
i had done coding in jsp i didnt used html pages
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

...

Clients (browsers) don't render JSP. They render HTML. HTML is what gets sent from the server to the client. HTML is what JavaScript acts on.

Post the rendered HTML.
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
i tried by entering the textfield in jsp using 's' prefix it is validating but not with drop-down box..and the html code is
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

So, the rendered HTML *does* give you a clue why your JavaScript doesn't work as you expect--right?
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
i m not getting your point and help me where the code gets wrong.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What's the id of the select element?
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
id of the select element is uploadtextContType..even if i had given..also it is not getting validated
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Do you know how to debug JavaScript?
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
i dont have any idea..can you tell me how to do.
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi good morning,
any help regarding my post why the drop-down is not getting validated.
thanks,
madhu.
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
i tried by entering the textfield..it is getting validated..but im facing problem with select box..is there any way to code..can anyone help me out..
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
i had changed my code and following is my jsp page..can any one help me why Select option is not getting validated.

and rendered Html file is

and corresponding login.js page


can any one provide me the solution.
thanks,
madhu.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Wouldn't it be cleaner to use a regex for the textfield validation? Or at least refactor out the validation code into its own method?
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi,
i tried this way for validation of combo box but im getting validated..here is the code.
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi good morning,
i m unable to do validation for select statement..i tried so many times..but im not getting ..here is the code..can any one help me out.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Works fine for me. I still think you should use a regex for that file thing though.

How will you be uploading the file without a file input?
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi David,
i tried to validate 'combobox' in normal jsp page it is working fine but not it in Struts2.You told it is working fine for you..my code is working fine for you and why not for me?have you done any changes..if so can you provide me the solution.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I ran your code against what you said was the generated HTML. It worked. I didn't change anything.
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
k..for me why it is not getting..here are the files..can you check it and provide me the solution
uploadText.jsp

rendered HTML Page is

UploadText.js

where i went wrong can you provide me the solution for my post
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I don't see how this is significantly different. Did you put a breakpoint or alert or console log to see if it's even getting to the code that validates the select?
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
i checked..till 'TextFile'..it is getting validated..and it is not getting validated for combo box..for Struts2 is there any other way for client side validation for Select statement
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

David Newton wrote:I don't see how this is significantly different. Did you put a breakpoint or alert or console log to see if it's even getting to the code that validates the select?
 
 
subject: unable to do validation for select in struts2