"Joe Kovac" <> wrote in message
news:728f0$46387352$3e63c322$.. .
> Hi!
>
> I want the user to edit a textbox which allows following values only:
> - Time (Format: 23:59, HH:MM)
> or
> - NULL (empty string)
> What can I do, so that this works kinda automatically, meaning on the
> client side. It would be also nice, that not only errors would be
> detected, but also that "wanted error" would be corrected if possible,
> e.g. exchange "30" by "00:30".
>
> Which control and properties do I need? As a reminder, I do not use a
> bound field but a TextBox.
I have a JavaScript function for this:
function isTime(pstrTime)
{
var strValidChars = "0123456789:";
var strChar;
if (pstrTime.length != 5) return false;
for (intChar = 0; intChar < pstrTime.length; intChar++)
{
strChar = pstrTime.charAt(intChar);
if (strValidChars.indexOf(strChar) == -1)
{
return false;
}
}
if (parseInt(pstrTime.substring(0, 2)) > 23) return false;
if (pstrTime.substring(2, 3) != ":") return false;
if (parseInt(pstrTime.substring(3)) > 59) return false;
return true;
}
--
http://www.markrae.net