Hi there.
Hi have this script: - <script language="javascript" type="text/javascript">
-
<!--
-
-
var fieldNames = new Array("IRE", "ISI", "IMI", "REL", "REV", "MAN", "SOP", "GUF", "FOR", "VAS");
-
-
function loaded()
-
{
-
-
var tm, q = location.href.indexOf("?tm=");
-
if (q < 0 || (tm = location.href.substr(q + 4)).length <= 0) return;
-
-
-
tm = tm.split(";");
-
-
var frmObj = document.timeForm;
-
-
var re = /^([a-z]+)-(([01]\d|2[0-3]):[0-5]\d)$/;
-
-
for ( var n = 0 ; n < tm.length ; n++ )
-
{
-
var rt = tm[n].match(re);
-
if (rt && typeof(frmObj[rt[1]]) != "undefined")
-
{
-
-
frmObj[rt[1]].value = rt[2];
-
}
-
}
-
}
-
-
function unloading()
-
{
-
-
if (window.opener == null) return;
-
-
window.opener.popupWin = null;
-
}
-
-
function updateTime(txtObj)
-
{
-
if (window.opener == null) return;
-
-
var re = /^([01]\d|2[0-3]):[0-5]\d$/;
-
-
if (txtObj.value.length >= 5 && !txtObj.value.match(re))
-
{
-
alert("Inserire l'orario nel formato 'hh:mm'.");
-
txtObj.focus();
-
}
-
-
var frmObj = txtObj.form;
-
var elems = frmObj.elements;
-
-
var result = "";
-
var destObj = window.opener.document.myform.impiego;
-
-
{
-
for ( var n = 0 ; n < elems.length ; n++ )
-
{
-
-
if (elems[n].type == "text" && elems[n].value.match(re))
-
{
-
if (result.length) result += ";";
-
-
result += elems[n].name + "-" + elems[n].value;
-
}
-
}
-
-
destObj.value= result;
-
}
-
else destObj.value= "--:--";
-
}
-
-
// -->
-
</script>
To perform control schedule.
That is schedule no superior to 7 hours and 36 minutes.
For example:
1) In the field of the form "IRE" inserted 08:00... this value is superior to 7:36
Its' wrong !!!!
2) In the field of the form "IRE" inserted 04:00 and in the field of the form "ISI" inserted 04:00.... this value is superior to 7:36
Its' wrong !!!!
Help me please, regards
viki1967
19 2303 acoder 16,027
Recognized Expert Moderator MVP
For each field, get the hours and minutes by splitting the input using split(). Use parseInt to convert into a number. Then add them up. If the hours are more than 7, then validation fails. If the hours equal 7, but the minutes exceed 36, again the validation fails. If you get stuck, post your attempt.
Sorry I not understand... for example ?
acoder 16,027
Recognized Expert Moderator MVP
For example, let's say you have 'field' which contains the input: - var vals = field.value.split(":");
-
var hours = parseInt(vals[0]);
-
var mins = parseInt(vals[1]);
-
// if this is in a loop, you could now add them to the total hours/mins:
-
totalHours += hours;
-
totalMins += mins;
-
// validate outside the loop
-
if (totalHours > 7) // error
-
if ((totalHours == 7) && (totalMins > 36)) // error here too.
-
Sorry Acoder... but how to integrate your code with code existing ?
Many Thanks....
acoder 16,027
Recognized Expert Moderator MVP
Where are you making the validation? In updateTime()?
Yes Acoder in UpdateTime()
acoder 16,027
Recognized Expert Moderator MVP
Just as you've used a loop in there, loop over the form elements in a similar manner: - var totalHours = 0;
-
var totalMins = 0;
-
for ( var n = 0 ; n < elems.length ; n++ )
-
{
-
if (elems[n].type == "text" && elems[n].value.match(re))
-
{
-
var vals = elems[n].value.split(":");
-
var hours = parseInt(vals[0]);
-
var mins = parseInt(vals[1]);
-
totalHours += hours;
-
totalMins += mins;
-
}
-
}
-
// validate outside the loop
-
if (totalHours > 7) // error
-
if ((totalHours == 7) && (totalMins > 36)) // error here too.
-
Sorry Acoder, but not working....
[php]
function updateTime(txtO bj)
{
if (window.opener == null) return;
var re = /^([01]\d|2[0-3]):[0-5]\d$/;
if (txtObj.value.l ength >= 5 && !txtObj.value.m atch(re))
{
alert("Inserire l'orario nel formato 'hh:mm'.");
txtObj.focus();
}
var frmObj = txtObj.form;
var elems = frmObj.elements ;
var result = "";
var destObj = window.opener.d ocument.myform. impiego;
if (frmObj.IRE.val ue.match(re))
var totalHours = 0;
var totalMins = 0;
{
for ( var n = 0 ; n < elems.length ; n++ )
{
if (elems[n].type == "text" && elems[n].value.match(re ))
{
var vals = elems[n].value.split(": ");
var hours = parseInt(vals[0]);
var mins = parseInt(vals[1]);
totalHours += hours;
totalMins += mins;
}
{
if (result.length) result += ";";
result += elems[n].name + "-" + elems[n].value;
}
}
destObj.value= result;
}
else destObj.value= "--:--";
// validate outside the loop
if (totalHours > 7) // error
if ((totalHours == 7) && (totalMins > 36)) // error here too.
}
[/php]
acoder 16,027
Recognized Expert Moderator MVP
There are two problems: one is that you want to validate before you calculate the result. So make two loops. The second problem is that where I've added comments, e.g. // error, you need to replace that with an error message.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Beringer |
last post by:
Hello,
I am creating a custom schedule control similar to the way Outlook behaves.
I am having some difficulty trying to graphically/visually resolve
conflicting appointments on a schedule.
Anyone have some ideas or a pointer or two to help me out?
Thanks,
|
by: cyshao |
last post by:
Hi, My Friends:
I have a program and I want to let machine automaticly auto it by using
Windows task schedule. Sure, I can manually Create/Modify task in Windows
task schedule. But I also hope to Create/Modify tasks by programming, for
another program want to generate many tasks.
Could you tell how to control windows task schedule by programming ?
Thanks
|
by: greg7224 |
last post by:
I am currently working on a C# project that uses the Janus schedule
controls, and am having trouble getting it to print correctly in Day
view. The problem is that it will not print out the owners of the
appointments unless I set the ShowAllDayArea parameter to true. When I
do this, a large and unsightly grey box is drawn above the actual
schedule in day view, wasting space and making things look generally
ugly.
I am using the built in...
|
by: Tinus |
last post by:
Hello all,
I've created a custom control that draws a monthly schedule (using the Draw
function in C#). Basically it draws 31 boxes and writes the day number in
every box.
This works great. But I now want to show a different tooltip for every day.
For now I found out that I can add a tooltip for the entire custom control
|
by: Danny Ni |
last post by:
Hi,
I have one user control named Schedule.ascx, I want to create another
control which is quite similar to schedule.ascx but differs in some methods
and some UI elements, the way I am doing it right now, I save schedule.ascx
as another name, say schedule2.ascx then I go to code behind and chane the
class name and the methods I like to change. Also modify the UI on ascx
file.
This is working. But there is a problem, evertime I change...
| |
by: Patrick |
last post by:
I am using VB to implement a code behind class for an
ASP.NET form. I am loading a DataGrid web server control
with data from a table in a SQL database. the code is as
follows:
Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Dim con As SqlConnection = New SqlConnection
|
by: John |
last post by:
Hello everyone,
I'm currently writing a program to keep track of schedule changes at a
school. The goal is to have someone using the program to declare changes,
then the program writes a html file, which is uploaded to a webserver. Then
students and teachers can view it online, but there are also a couple of
computers with 19" monitors standing around the school to display the
webpage (IE kiosk mode).
The program has a form containing...
|
by: Yoram Biberman |
last post by:
I have a few questions concerning concurrency control. I shall thank whoever
can help me.
Question #1
=========
Assume the following (concurrent) schedule, in which both transactions run
in a serializable isolation level:
T1 begin
T2 begin
T1 modifies an item A
|
by: Prakash |
last post by:
Hi Friends,
I am developing scheduler application using C#. For displaying all
schedule information i am using ListView control. Based on the status
of the schedule, i have displayed the schedule information in the list
view as seperate colors.
I have faced the problem with deselecting the list view item. For
example, if i select the first row,(with blue color) of the list view
and deactivate the selected item by clicking the row...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |