Ciao vorrei inserire alcune comode funzionalità di controllo date dal framwork spry inserite in cs4 con alcuni ( in questo caso uno ) controlli sui campi già presenti nel sito.
In questo caso ho una select che in base al valore scelto mi invia il form oppure mi dice di scegliere una voce.
---------------------------------------------
codice:
function controlloSelect(){
n=document.forms['prod'].elements['cliente']
if(n.selectedIndex==0){
alert('Selezionare un cliente');
return false;
n.focus();
}
else 

document.forms['prod'].submit();
}
/// questo è l'evento sulla select /// onChange="return controlloSelect()"
-----------------------
ora vorrei inserire un controllo di spry su un campo data, inserendo il tutto in maniera automatica il controllo data funziona ma viene bypassato subito dal form submit quando scelgo il cliente nella select.
La mia domanda è: sapere se è possibile e se in caso affermativo si tratta di inserire la funzione sopra dentro quella della data.
Grazie, ciao.
Ecco il file js di spry dove verifica la data
--------------------------------------------------------
codice:
'date': {
		validation: function(value, options) {
			var formatRegExp = /^([mdy]+)[\.\-\/\\\s]+([mdy]+)[\.\-\/\\\s]+([mdy]+)$/i;
			var valueRegExp = this.dateValidationPattern;
			var formatGroups = options.format.match(formatRegExp);
			var valueGroups = value.match(valueRegExp);
			if (formatGroups !== null && valueGroups !== null) {
				var dayIndex = -1;
				var monthIndex = -1;
				var yearIndex = -1;
				for (var i=1; i<formatGroups.length; i++) {
					switch (formatGroups[i].toLowerCase()) {
						case "dd":
							dayIndex = i;
							break;
						case "mm":
							monthIndex = i;
							break;
						case "yy":
						case "yyyy":
							yearIndex = i;
							break;
					}
				}
				if (dayIndex != -1 && monthIndex != -1 && yearIndex != -1) {
					var maxDay = -1;
					var theDay = parseInt(valueGroups[dayIndex], 10);
					var theMonth = parseInt(valueGroups[monthIndex], 10);
					var theYear = parseInt(valueGroups[yearIndex], 10);

					// Check month value to be between 1..12
					if (theMonth < 1 || theMonth > 12) {
						return false;
					}
					
					// Calculate the maxDay according to the current month
					switch (theMonth) {
						case 1:	// January
						case 3: // March
						case 5: // May
						case 7: // July
						case 8: // August
						case 10: // October
						case 12: // December
							maxDay = 31;
							break;
						case 4:	// April
						case 6: // June
						case 9: // September
						case 11: // November
							maxDay = 30;
							break;
						case 2: // February
							if ((parseInt(theYear/4, 10) * 4 == theYear) && (theYear % 100 != 0 || theYear % 400 == 0)) {
								maxDay = 29;
							} else {
								maxDay = 28;
							}
							break;
					}

					// Check day value to be between 1..maxDay
					if (theDay < 1 || theDay > maxDay) {
						return false;
					}
					
					// If successfull we'll return the date object
					return (new Date(theYear, theMonth - 1, theDay));   //JavaScript requires a month between 0 and 11
				}
			} else {
				return false;
			}
		}
	},