Solved

Javascript validation

Posted on 2011-02-22
10
200 Views
Last Modified: 2012-05-11
Hello,

I'm trying to make a logic for a validation.  

This is my scenario.

I have a screen that have two Lines,

Record 1 and Record 2
each record have 6 days and 6 hours.

The hours are from 7:00 AM to 6:00 PM and the days are from 1 to 31.

The hours values go from fifteen to fifteen .
7:00 AM, 7:15 AM, 7:30 AM, 7:45 AM, 8:00 AM. (this wil be in a drop down
I have this condition groups 30 minutes can have a max of 2 day selected and a group of 45 minutes can have a max of 4 day selected.

I have to verify that if  group start at  11:00 on day one it can only have 2 records selected, but if it have more than 2 and a max of 4, the next group of the same day have to start at 11:45, not before, if the group was just from 2 then the next group day will be of 11:30.

I was trying to use a for next, but I'm not really sure if that is the way to do it.

Record1:
Day1 Hour1,  Day2 Hour2,  Day3 Hour3,  Day4 Hour4,  Day5 Hour5,  Day6 Hour6,  

Record2:
Day1 Hour1,  Day2 Hour2,  Day3 Hour3,  Day4 Hour4,  Day5 Hour5,  Day6 Hour6,  

This have to be in java script because are just with the records on the screen
0
Comment
Question by:cano63
  • 7
  • 3
10 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
1. I added the JavaScript zone to your question
2. Can you post your html, since your question does not make much sense
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Not quite.

You did not post enough information for us to help you and the information you DID post was not clearly understandable without code or diagrams
0
 
LVL 1

Author Comment

by:cano63
Comment Utility
I don,t have a diagram, but this is the problem.

Here is the problem:

I have a screen that will have the following values

Record1:
Day1 Hour1,  Day2 Hour2,  Day3 Hour3,  Day4 Hour4,  Day5 Hour5,  Day6 Hour6,  

Record2:
Day1 Hour1,  Day2 Hour2,  Day3 Hour3,  Day4 Hour4,  Day5 Hour5,  Day6 Hour6,  

each record will have 12 drop downs, This will be in pair of 2 , the Days drop down will have days from 1 -31 and the drop down of hours will have time from 7:00 AM to 6:45 PM divided in sequence of 15 minutes, 7:00 AM - 7:15:00 AM - 7:30 AM, like that.

Each record have one student, and one student can be occupied on a specific day at specific time.

If the student work alone he can just work 30 minutes, and if the student work on group he will be able to work with a maximums of 4 students and just 45 minutes.

My rule have to verify that this student don't, be working the same day and the same time in other of the records and that he don't pass the amount of 30 minutes alone and 45 minutes with a max of 4 users.


0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Is this homework?

If so can you please post the html that goes with the tests so I do not have to write it  - it will help me find out where to put the tests
0
 
LVL 1

Author Comment

by:cano63
Comment Utility
No, is not for homework, is for a production application tha will be running in a center of services.

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Ok I would stil like to have a start
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Because no code from the asker... I love to HELP people, not write all their code for free...
0
 
LVL 1

Author Comment

by:cano63
Comment Utility
Let me know is this help, this is the html of the jsp

This will be 13 records, i,m just copying 2
<table border="0" class="tablewidth4">
							<tbody>
								<tr>
									<td align="center" width="49"><span class="labelsBold">Record:</span></td>
									<td width="117">
									<table>
										<tbody>
											<tr>
												<td width="115" align="center"><span class="labelsBold">Number</span></td>
											</tr>
										</tbody>
									</table>									</td>
									<td width="116" align="center"><span class="labelsBold">Name</span></td>
									<td width="57" align="center"><span class="labelsBold">Age</span></td>
									<td width="107" align="center"><span class="labelsBold">Place</span></td>
									<td width="114" align="center">Town</td>
									<td align="center" width="122"><span class="labelsBold">Entity</span></td>
									<td align="center" width="138"><table border="0">
										<tbody valign="top">
											<tr valign="top">
												<td id="Terapia1" align="center" width="51"><span
													class="labelsBold">Therapy</span></td>
												<td id="Evaluacion1" align="center" width="52"><span class="labelsBold">Therapy</span></td>
											</tr>
											<tr valign="top">
											  <td id="Terapia3" align="center">&nbsp;</td>
											  <td id="Evaluacion3" align="center">&nbsp;</td>
										  </tr>
										</tbody>
									</table>									</td>
									<td align="center" width="86"><table
										border="0">
										<tbody>
											<tr>
												<td id="Lugar1" ><span class="labelsBold">Place:</span></td>
											</tr>
										</tbody>
									</table>									</td>
									<td width="12"><span class="labelsBold"></span></td>
								</tr>
								<tr>
									<td align="center" width="49"><span class="labelsBold">1:</span></td>
									<td align="center" width="117"><input type="text" name="txtNumber1" size="20" class="inputField" onchange="search('1')"></td>
									<td width="116" align="center"><input type="text" name="txtEst1" size="20" class="inputField2" readonly></td>
									<td width="57" align="center"><input type="text" name="txtedad1" size="20" class="inputField8" readonly></td>
									<td width="107" align="center"><input type="text" name="txtEsc1" size="20" class="inputField" readonly></td>
									<td width="114" align="center"><input type="text" name="txtDis1" size="20" readonly class="inputField"></td>
									<td align="center" width="122"><input type="text" name="txtPu1" size="20" readonly class="inputField"></td>
									<td align="center" width="138"><select name="dpTip1" id="dpTip1" class="inputField13" onchange="place(1)">
									<option></option>

									</select> </td>
									<td align="center" width="86"><input type="text" name="txtCen1" size="20" class="inputField14" readonly></td>
									<td align="center" width="12">										 </td>
								</tr>
								<tr>
									<td align="center" width="49">
									<table border="0">
										<tbody>
											<tr>
												<td align="center"><span class="labelsBold"></span></td>
											</tr>
											<tr>
												<td align="center">													</td>
											</tr>
										</tbody>
									</table>									</td>
									<td colspan="9">
									<table border="0">
										<tbody>
											<tr>
												<td><span class="labelsBold">Day-1:</span></td>
												<td><span class="labelsBold">Time1:</span></td>
												<td><span class="labelsBold">Day-2:</span></td>
												<td><span class="labelsBold">Time2:</span></td>
												<td><span class="labelsBold">Day-3:</span></td>
												<td><span class="labelsBold">Time3:</span></td>
												<td><span class="labelsBold">Day-4:</span></td>
												<td><span class="labelsBold">Time4:</span></td>
												<td><span class="labelsBold">Day-5:</span></td>
												<td><span class="labelsBold">Time5:</span></td>
												<td><span class="labelsBold">Day-6:</span></td>
												<td><span class="labelsBold">Time6:</span></td>
											</tr>
											<tr>
												<td><select name="dpDia1_1">

													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpHora1_1">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpDia1_2">
													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpHora1_2">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpDia1_3">
													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpHora1_3">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpDia1_4">
													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpHora1_4">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpDia1_5">

													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>

												</select></td>
												<td><select name="dpHora1_5">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpDia1_6">
													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpHora1_6">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
											</tr>
										</tbody>
									</table>									</td>
								</tr>
								<tr>
									<td colspan="10">
									<hr>									</td>
								</tr>
								<tr>
									<td align="center" width="49"><span class="labelsBold">Record:</span></td>
									<td align="center" width="117"><span class="labelsBold">Number</span></td>
									<td width="116" align="center"><span class="labelsBold">Name:</span></td>
									<td width="57" align="center"><span class="labelsBold">Age</span></td>
									<td width="107" align="center"><span class="labelsBold">Place:</span></td>
									<td width="114" align="center"><span class="labelsBold">Town:</span></td>
									<td align="center" width="122"><span class="labelsBold">Entity</span></td>
									<td align="center" width="138"><table border="0">
										<tbody valign="top">
											<tr valign="top">
												<td id="Terapia2" align="center" width="51"><span class="labelsBold">Therapy</span></td>
												<td id="Evaluacion2" align="center" width="52"><span class="labelsBold">Therapy</span></td>
											</tr>
										</tbody>
									</table>									</td>
									<td align="center" width="86"><table border="0">
										<tbody>
											<tr>
												<td id="Lugar2"><span class="labelsBold">Place:</span></td>
											</tr>
										</tbody>
									</table>									</td>
									<td width="12"></td>
								</tr>
								<tr>
									<td align="center" width="49"><span class="labelsBold">2:</span></td>
									<td align="center" width="117"><input type="text" name="txtNumber2" size="20" class="inputField" onchange="search('2')"></td>
									<td width="116" align="center"><input type="text" name="txtEst2" size="20" class="inputField2" readonly></td>
									<td width="57" align="center"><input type="text" name="txtedad2" size="20" class="inputField8" readonly></td>
									<td width="107" align="center"><input type="text" name="txtEsc2" size="20" class="inputField" readonly></td>
									<td width="114" align="center"><input type="text" name="txtDis2" size="20" readonly class="inputField"></td>
									<td align="center" width="122"><input type="text" name="txtPu2" size="20" readonly class="inputField"></td>
									<td align="center" width="138"><select name="dpTip2" id="dpTip2" onchange="place(2)" class="inputField13">

										<option></option>
									</select></td>
									<td align="center" width="86"><input type="text" name="txtCen2" size="20" class="inputField14" readonly></td>
									<td align="center" width="12"></td>
								</tr>
								<tr>
									<td align="center" width="49">
									<table border="0">
										<tbody>
											<tr>
												<td align="center"></td>
											</tr>
											<tr>
												<td align="center"></td>
											</tr>
										</tbody>
									</table>									</td>
									<td colspan="9">
									<table border="0">
										<tbody>
											<tr>
												<td><span class="labelsBold">Day-1:</span></td>
												<td><span class="labelsBold">Time1:</span></td>
												<td><span class="labelsBold">Day-2:</span></td>
												<td><span class="labelsBold">Time2:</span></td>
												<td><span class="labelsBold">Day-3:</span></td>
												<td><span class="labelsBold">Time3:</span></td>
												<td><span class="labelsBold">Day-4:</span></td>
												<td><span class="labelsBold">Time4:</span></td>
												<td><span class="labelsBold">Day-5:</span></td>
												<td><span class="labelsBold">Time5:</span></td>
												<td><span class="labelsBold">Day-6:</span></td>
												<td><span class="labelsBold">Time6:</span></td>
											</tr>
											<tr>
												<td><select name="dpDia2_1">

													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpHora2_1">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpDia2_2">

													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpHora2_2">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpDia2_3">

													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpHora2_3">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpDia2_4">

													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpHora2_4">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpDia2_5">

													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpHora2_5">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpDia2_6">

													<c:forEach var="item" items="${Dias.dias}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
												<td><select name="dpHora2_6">
													<c:forEach var="item" items="${Horas.horas}">
														<option value="${item}">${item}</option>
													</c:forEach>
												</select></td>
											</tr>
										</tbody>
									</table>									</td>
								</tr>
								<tr>
									<td colspan="10">
									<hr>									</td>
								</tr>
							</tbody>
						</table>

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Great. I'll look tomorrow (in about 10 hours) bedtime here
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
Comment Utility
Hmm

I have read these two lines many times. It does not give me any clear algorithm

I have this condition groups 30 minutes can have a max of 2 day selected and a group of 45 minutes can have a max of 4 day selected.

I have to verify that if  group start at  11:00 on day one it can only have 2 records selected, but if it have more than 2 and a max of 4, the next group of the same day have to start at 11:45, not before, if the group was just from 2 then the next group day will be of 11:30.

What are "groups" and do you have to generate the time and day numbers on the server? If so, can you give me the records with the dropdowns filled in? (view-source)

If you could show me a screen shot of something correct and another of an error, I would have something to go on

Thanks
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
jquery, dropdown 4 33
using web browser with BING 40 82
How can i make a popup form from clicking on a button 4 18
Phone Dialer 5 33
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now