Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Date and Month validation in JSP  RSS feed

 
nalini peddareddy
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a program with 2 combo boxes .One for date and one for the month.
When i select january it has to give me 31 days and 28 days for Feb.In case it is a leap year then it has to give me 29 days.

I have written a code for the combo boxes..but could any of u help me out or provide me with some learning as how to map those day and month.

Here is my small code..
FONT class="def_pos2">Date of Birth<br><b> (Required Format: MM/DD/YYYY)</B></FONT></TD>
<TD width="50%">

<SELECT name="MonthOfBirth" WIDTH="25">
<% for(int i=1;i<=12;i++) {%>
<OPTION value=" <%= i %> " > <%= i %></OPTION>
<% } %>
</SELECT>

/ <SELECT name="DayOfBirth" WIDTH="25">
<% for(int i=1;i<=31;i++) {%>
<OPTION value=" <%= i %> " > <%= i %></OPTION>
<% } %>
</SELECT>




Please help me out..


Thanks and Regards,
Nalini.
 
Kedar Dravid
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you are probably talking about dependent combo boxes.
Here, you might want to try out the IFRAME element to change the values in one combo box depending upon the values in another combo box, without submitting the form.
 
Tarun Gandhi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can submit the form on selection of the month using javascript to the same page. You can then get the selected month from request parameter and display the day combo accordingly.

The other alternative will be of relying on javascript solely.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As there are only 12 data points, a Javascript-only solution would be fairly straight-forward. The only sticky point might be the leap year determination. Although, as I recall, there's an alogorithm to determine if a year is a leap year or not that you could look up.
 
Niki Nono
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[bear edit: "me too!" post removed]
[ August 03, 2005: Message edited by: Bear Bibeault ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!