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 - s:select name="Type" label="Type" headerKey="1" headerValue="-- Please Select --"
-
list="#{'01':'News','02':'Jokes','03':'Astrology','04':'Weather',
-
'05':'Traffic','06':'Sports','07':'Prayer'}" />
login.js - if (form.Type.selectedIndex < 0)
-
{
-
alert("Select \"Type\" options.");
-
form.Type.focus();
-
return (false);
-
}
thanks in advance,
madhu.
10 3784
Maybe -
if (form.Type.selectedIndex == 0){
-
alert("Select \"Type\" options.");
-
form.Type.focus();
-
return (false);
-
}
hi Canabeez,
Even though i tried what you suggested but it not getting..is there any other way for the validation.
I'm not that good at jsp, can you please post some generated HTML or a link to a sample page.
hi Canabeez,
the following is rendered Html page..can u provide me why im not getting -
<html>
-
<head>
-
<title>Upload Text Content</title>
-
<script type="text/javascript" src="/Cms/js/UploadGameContent.js"></script>
-
</head>
-
<body>
-
<form id="" action="" method="POST">
-
<table class="wwFormTable">
-
<table align="center" width=610 cellspacing=0 cellpadding=3 style="border:1px solid gray">
-
<tr>
-
<td class="tdLabel"><label for="UploadTextTitle" class="label">ContentTitle :</label></td>
-
<td><input type="text" name="ContentTextTitle" value="" id="UploadTextTitle"/></td>
-
</tr>
-
<tr>
-
<td class="tdLabel"><label for="UploadTextDesc" class="label">ContentDescription :</label></td>
-
<td><input type="text" name="ContentTextDescription" value="" id="UploadTextDesc"/></td>
-
</tr>
-
<tr>
-
<td class="tdLabel"><label for="UploadTextTags" class="label">ContentTags :</label></td>
-
<td><input type="text" name="ContentTextTags" value="" id="UploadTextTags"/></td>
-
</tr>
-
<tr>
-
<td class="tdLabel"><label for="UploadTextExpiry" class="label">ExpiryDate :</label></td>
-
<td><input type="text" name="TextExpiryDate" value="" id="UploadTextExpiry"/></td>
-
</tr>
-
<tr>
-
<td class="tdLabel"><label for="UploadTextCost" class="label">Text Cost :</label></td>
-
<td><input type="text" name="TextCost" value="" id="UploadTextCost"/></td>
-
</tr>
-
<tr>
-
<td class="tdLabel"><label for="UploadTextFile" class="label">Text File :</label></td>
-
<td><input type="text" name="TextFile" value="" id="UploadTextFile"/></td>
-
</tr>
-
<tr>
-
<td class="tdLabel"><label for="UploadTextType" class="label">Text Type:</label></td>
-
<td><select name="TextType" id="UploadTextType">
-
<option value="1"
-
>-- Please Select --</option>
-
<option value="01">News</option>
-
<option value="02">Jokes</option>
-
<option value="03">Astrology</option>
-
<option value="04">Weather</option>
-
<option value="05">Traffic</option>
-
<option value="06">Sports</option>
-
<option value="06">Prayer</option>
-
</select></td>
-
</tr>
-
<tr>
-
<td colspan="2"><div align="center"><button type="submit" id="_0" value="Upload" onClick="validate(this.form);">
-
Upload
-
</button>
-
</div></td>
-
</tr>
-
</table>
-
</table></form>
-
</body>
-
</html>
-
It's stupid, but did you try -
if (form.TextType.selectedIndex == 0){
-
alert("Select \"Type\" options.");
-
form.TextType.focus();
-
return (false);
-
}
-
hi Canabeez,
i tried using wht u suggested..i tried like tht only..but i didnt getting validated.
Try this: -
if( document.getElementById('UploadTextType').selectedIndex == 0){
-
alert("Select \"Type\" options.");
-
document.getElementById('UploadTextType').focus();
-
return (false);
-
}
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 - <%@ page contentType="text/html; charset=UTF-8" %>
-
<%@ taglib prefix="s" uri="/struts-tags" %>
-
-
<html>
-
<head>
-
<title>Upload Game Content</title>
-
<script type="text/javascript" src="/Cms/js/UploadGameContent.js"></script>
-
</head>
-
<body>
-
<s:form action="" method="POST">
-
<table align="center" width=610 cellspacing=0 cellpadding=3 style="border:1px solid gray">
-
<s:textfield name="ContentGameTitle" id="UploadGameTitle" label="ContentTitle "/>
-
<s:textfield name="ContentGameDescription" id="UploadGameDesc" label="ContentDescription "/>
-
<s:textfield name="ContentGameTags" id="UploadGameTags" label="ContentTags "/>
-
<s:textfield name="GameExpiryDate" id="UploadGameExpiry" label="ExpiryDate "/>
-
<s:textfield name="GameCost" id="UploadGameCost" label="Game Cost "/>
-
<s:textfield name="GameFile" id="UploadGameFile" label="Game File "/>
-
<s:select name="GameType" id="UploadGameType" label="Game Type" headerKey="1" headerValue="-- Please Select --"
-
list="#{'01':'SIS','02':'Jar','03':'SISX','04':'APK','05':'SIS60','06':'SIS9'}" />
-
<s:submit type="button" value="Upload" align="center" onClick="validate(this.form);"/>
-
</table>
-
</s:form>
-
</body>
-
</html>
the js file is - function validate(form)
-
{
-
if (form.ContentGameTitle.value == 0)
-
{
-
alert("Enter Content Game Title");
-
form.ContentGameTitle.focus();
-
return (false);
-
}
-
if (form.ContentGameDescription.value == 0)
-
{
-
alert("Enter Content Game Description");
-
form.ContentGameDescription.focus();
-
return (false);
-
}
-
if (form.ContentGameTags.value == 0)
-
{
-
alert("Enter Content Game Tags");
-
form.ContentGameTags.focus();
-
return (false);
-
}if (form.GameExpiryDate.value == 0)
-
{
-
alert("Enter Content Game Expiry Date");
-
form.GameExpiryDate.focus();
-
return (false);
-
}if (form.GameCost.value == "")
-
{
-
alert("Enter Content Game Cost");
-
form.GameCost.focus();
-
return (false);
-
}if (form.GameFile.value == 0)
-
{
-
alert("Enter Content Game File");
-
form.GameFile.focus();
-
return (false);
-
}if( document.getElementById('UploadTextType').selectedIndex == 0){
-
alert("Select \"Type\" options.");
-
document.getElementById('UploadTextType').focus();
-
return (false);
-
}document.form.submit();
-
return true;
-
can u chk it nd provide me the solution
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: SallyAtwood |
last post by:
I have a text box that I cannot select by any of the conventional means. Any ideas?
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
|
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,...
|
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,...
|
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...
| |