473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

unable to do validation for select in struts2

149 100+
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
Expand|Select|Wrap|Line Numbers
  1. s:select name="Type" label="Type" headerKey="1"  headerValue="-- Please Select --"
  2.                           list="#{'01':'News','02':'Jokes','03':'Astrology','04':'Weather',
  3.                                   '05':'Traffic','06':'Sports','07':'Prayer'}" />
login.js
Expand|Select|Wrap|Line Numbers
  1. if (form.Type.selectedIndex < 0)
  2.     {
  3.         alert("Select \"Type\" options.");
  4.         form.Type.focus();
  5.         return (false);
  6.     }
thanks in advance,
madhu.
Sep 8 '10 #1
10 3784
madhuriks
149 100+
any help reg my post
Sep 8 '10 #2
madhuriks
149 100+
regarding this any help
Sep 8 '10 #3
Canabeez
126 100+
Maybe
Expand|Select|Wrap|Line Numbers
  1. if (form.Type.selectedIndex == 0){
  2.         alert("Select \"Type\" options.");
  3.         form.Type.focus();
  4.         return (false);
  5. }
Sep 11 '10 #4
madhuriks
149 100+
hi Canabeez,
Even though i tried what you suggested but it not getting..is there any other way for the validation.
Sep 13 '10 #5
Canabeez
126 100+
I'm not that good at jsp, can you please post some generated HTML or a link to a sample page.
Sep 13 '10 #6
madhuriks
149 100+
hi Canabeez,
the following is rendered Html page..can u provide me why im not getting
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Upload Text Content</title>
  4. <script type="text/javascript" src="/Cms/js/UploadGameContent.js"></script>
  5. </head>
  6. <body>
  7. <form id="" action="" method="POST">
  8. <table class="wwFormTable">
  9. <table align="center" width=610 cellspacing=0 cellpadding=3 style="border:1px solid gray">
  10. <tr>
  11. <td class="tdLabel"><label for="UploadTextTitle" class="label">ContentTitle :</label></td>
  12. <td><input type="text" name="ContentTextTitle" value="" id="UploadTextTitle"/></td>
  13. </tr>
  14. <tr>
  15. <td class="tdLabel"><label for="UploadTextDesc" class="label">ContentDescription :</label></td>
  16. <td><input type="text" name="ContentTextDescription" value="" id="UploadTextDesc"/></td>
  17. </tr>
  18. <tr>
  19. <td class="tdLabel"><label for="UploadTextTags" class="label">ContentTags :</label></td>
  20. <td><input type="text" name="ContentTextTags" value="" id="UploadTextTags"/></td>
  21. </tr>
  22. <tr>
  23. <td class="tdLabel"><label for="UploadTextExpiry" class="label">ExpiryDate :</label></td>
  24. <td><input type="text" name="TextExpiryDate" value="" id="UploadTextExpiry"/></td>
  25. </tr>
  26. <tr>
  27. <td class="tdLabel"><label for="UploadTextCost" class="label">Text Cost :</label></td>
  28. <td><input type="text" name="TextCost" value="" id="UploadTextCost"/></td>
  29. </tr>
  30. <tr>
  31. <td class="tdLabel"><label for="UploadTextFile" class="label">Text File :</label></td>
  32. <td><input type="text" name="TextFile" value="" id="UploadTextFile"/></td>
  33. </tr>
  34. <tr>
  35. <td class="tdLabel"><label for="UploadTextType" class="label">Text Type:</label></td>
  36. <td><select name="TextType" id="UploadTextType">
  37.     <option value="1"
  38.     >-- Please Select --</option>
  39.     <option value="01">News</option>
  40.     <option value="02">Jokes</option>
  41.     <option value="03">Astrology</option>
  42.     <option value="04">Weather</option>
  43.     <option value="05">Traffic</option>
  44.     <option value="06">Sports</option>
  45.     <option value="06">Prayer</option>
  46. </select></td>
  47. </tr>
  48. <tr>
  49. <td colspan="2"><div align="center"><button type="submit" id="_0" value="Upload" onClick="validate(this.form);">
  50. Upload
  51. </button>
  52. </div></td>
  53. </tr>
  54. </table>
  55. </table></form>
  56. </body>
  57. </html>
  58.  
Sep 13 '10 #7
Canabeez
126 100+
It's stupid, but did you try
Expand|Select|Wrap|Line Numbers
  1. if (form.TextType.selectedIndex == 0){
  2.         alert("Select \"Type\" options.");
  3.         form.TextType.focus();
  4.         return (false);
  5. }
  6.  
Sep 13 '10 #8
madhuriks
149 100+
hi Canabeez,
i tried using wht u suggested..i tried like tht only..but i didnt getting validated.
Sep 14 '10 #9
Canabeez
126 100+
Try this:
Expand|Select|Wrap|Line Numbers
  1. if( document.getElementById('UploadTextType').selectedIndex == 0){
  2.         alert("Select \"Type\" options.");
  3.         document.getElementById('UploadTextType').focus();
  4.         return (false);
  5. }
Sep 14 '10 #10
madhuriks
149 100+
hi Canabeez,
i tried what u suggested.it is getting i take it in individual jsp.but if im implementing in the following jsp.it is not getting validated..here is my jsp code
Expand|Select|Wrap|Line Numbers
  1. <%@ page contentType="text/html; charset=UTF-8" %>
  2. <%@ taglib prefix="s" uri="/struts-tags" %>
  3.  
  4. <html>
  5.     <head>
  6.         <title>Upload Game Content</title>
  7.         <script type="text/javascript" src="/Cms/js/UploadGameContent.js"></script>
  8.     </head>
  9.     <body>
  10.     <s:form action="" method="POST">
  11.         <table align="center" width=610 cellspacing=0 cellpadding=3 style="border:1px solid gray">
  12.             <s:textfield name="ContentGameTitle" id="UploadGameTitle" label="ContentTitle "/>
  13.             <s:textfield name="ContentGameDescription" id="UploadGameDesc" label="ContentDescription "/>
  14.             <s:textfield name="ContentGameTags" id="UploadGameTags" label="ContentTags "/>
  15.             <s:textfield name="GameExpiryDate" id="UploadGameExpiry" label="ExpiryDate "/>
  16.             <s:textfield name="GameCost" id="UploadGameCost" label="Game Cost "/>
  17.             <s:textfield name="GameFile" id="UploadGameFile" label="Game File "/>
  18.             <s:select name="GameType" id="UploadGameType" label="Game Type" headerKey="1" headerValue="-- Please Select --"
  19.                       list="#{'01':'SIS','02':'Jar','03':'SISX','04':'APK','05':'SIS60','06':'SIS9'}" />
  20.             <s:submit type="button" value="Upload" align="center" onClick="validate(this.form);"/>
  21.         </table>
  22.     </s:form>
  23. </body>
  24. </html>
the js file is
Expand|Select|Wrap|Line Numbers
  1. function validate(form)
  2. {
  3.     if (form.ContentGameTitle.value == 0)
  4.     {
  5.         alert("Enter Content Game Title");
  6.         form.ContentGameTitle.focus();
  7.         return (false);
  8.     }
  9.     if (form.ContentGameDescription.value == 0)
  10.     {
  11.         alert("Enter Content Game Description");
  12.         form.ContentGameDescription.focus();
  13.         return (false);
  14.     }
  15. if (form.ContentGameTags.value == 0)
  16.     {
  17.         alert("Enter Content Game Tags");
  18.         form.ContentGameTags.focus();
  19.         return (false);
  20.     }if (form.GameExpiryDate.value == 0)
  21.     {
  22.         alert("Enter Content Game Expiry Date");
  23.         form.GameExpiryDate.focus();
  24.         return (false);
  25.     }if (form.GameCost.value == "")
  26.     {
  27.         alert("Enter Content Game Cost");
  28.         form.GameCost.focus();
  29.         return (false);
  30.     }if (form.GameFile.value == 0)
  31.     {
  32.         alert("Enter Content Game File");
  33.         form.GameFile.focus();
  34.         return (false);
  35.     }if( document.getElementById('UploadTextType').selectedIndex == 0){
  36.         alert("Select \"Type\" options.");
  37.         document.getElementById('UploadTextType').focus();
  38.         return (false);
  39.     }document.form.submit();
  40.     return true;
  41.  
can u chk it nd provide me the solution
Sep 15 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Alex Glaros | last post by:
I need help on my basic table connection syntaxt using PHP. I call the php from a web browser url_name_goes_here/test.php. The database name is tennis and the user name is tennis. If I type...
2
by: Andy S. | last post by:
Hi, I'm trying to declare and use temporary tables. I have written the following code in Java. Creating the tablespace (i can see the tablespace created using the Control Center), the temporary...
0
by: Islam Elkhayat | last post by:
In my Application i search my Employee database and view result in List View with 3 column.. here is the code: ######################################### private void textBox1_TextChanged(object...
2
by: rsquarev | last post by:
Hi, I am getting a problem regarding textboxes. In my application I am using a framework, which provides the page base for my application, It's just designing of page. But by using this I am not...
0
by: yawnmoth | last post by:
<?php while (true) { $read = array(STDIN); $write = $except = NULL; if (stream_select($read, $write, $except, 0)) { } } ?> When I run this in PHP4, I get a "warning: stream select(): unable...
7
by: robtyketto | last post by:
Greetings, I'm using XMLspy and haveing problem selecting any child nodes under complex element type <DeliveryInfo> Can anyone point out where im going wrong? Im a complete newbie to XML, XSD...
3
by: ashishc | last post by:
Hi All, I have written a AutoSuggest in jsp and am using javascript to call the strut page which calls the database and returns me the xml back. On the html page i have a text box where i enter...
1
by: SallyAtwood | last post by:
I have a text box that I cannot select by any of the conventional means. Any ideas?
4
maxamis4
by: maxamis4 | last post by:
I currently have an input form in HTML. I am trying to use JavaScript to validate that the html forms are entered. I had it working earlier today but now my form is not validating. Could someone take...
2
by: balajihr | last post by:
Hi All, The below query works well, but I'm unable to select * columns or selected columns from 2 tables. select FIAS_ID, ACTION_ID from CTH_ABAL_FIAS_HISTORY where ACTION_ID = 535 OR...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.