Sorry Acoder... but how to integrate your code with code existing ?
Many Thanks....
Perform control schedule
Collapse
X
-
For example, let's say you have 'field' which contains the input:
[code=javascript]var vals = field.value.spl it(":");
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.
[/code]Leave a comment:
-
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.Leave a comment:
-
Perform control schedule
Hi there.
Hi have this script:
Code:<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
viki1967Tags: None
Leave a comment: