Hi, I'm just having a issue with trying to constrain a input box to only let 24 hour time be inputted, eg; 13:30, 09:00, etc.
With the code I have now it output's the alert even if the format is correct. It's probably something really obvious but I have been at it a while now so I'm hoping someone can make me look really stupid
Heres the code:
In_String = input.Custom_Time; //Gives variable "In_String" the value of Custom_Time inputted by user
Number = "1234567890"; //Defines variable "Number" to hold number values
Retval = false; //Creates value "Retval" to false
if ((input.In_String).length() == (input.Custom_Time).length())
{
First_In_String = (input.In_String).subString(0,1);//Variable to hold the hours inputted by user
Sec_In_String = (input.In_String).subString(2);//Variable to hold ":" symbol inputted by user
Third_In_String = (input.In_String).subString(3,4);//Variable to hold the minutes inputted by user
if (First_In_String == (Number))
{
Retval = true;
}
else if (Sec_In_String == (":"))
{
Retval = true;
}
else if (Third_In_String == (Number))
{
Retval = true;
}
else
{
Retval = false;
}
}
if (Retval == false)
{
alert "You must enter a time in 24 hour format, eg; 13:30 for 1.30 pm";