You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matt Raible <ma...@yahoo.com> on 2001/07/23 22:18:03 UTC
Validation: validate "time" entry
Does anyone know of a "time" validation that I can add to my validation.xml
file. It would be similar to the entry below (I figure), but would validate
the time is between 0:00 and 12:00, or 0:00 and 24:00
<validator
name="integer"
classname="com.wintecinc.struts.validation.StrutsValidator"
method="validateInteger"
depends="required"
msg="errors.integer">
<javascript><![CDATA[
function validateInteger(form) {
var bValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oInteger = new integer();
for (x in oInteger) {
if ((form[oInteger[x][0].type == 'text' ||
form[oInteger[x][0].type == 'textarea' || form[oInteger[x][0].type == 'select'
|| form[oInteger[x][0].type == 'radio') && form[oInteger[x][0].value.length >
0) {
var iValue = parseInt(form[oInteger[x][0].value);
if (!iValue || !(iValue >= -2147483648 && iValue <=
2147483647)) {
if (i == 0)
focusField = form[oInteger[x][0];
fields[i++] = oInteger[x][1];
bValid = false;
}
}
}
if (fields.length > 0) {
focusField.focus();
alert(fields.join('\n'));
}
return bValid;
}]]>
</javascript>
</validator>
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/