I have a textbox need to input time as integer (i.e. 8:26, I need to input 826). Then I want to validate if this input has valid minutes. For example, if I input 860 or 867, it will be not correct as minute must be less than 60.
How can I do it in C#? I wrote a method but it does not work. See below:
protected void Button1_Click(object sender, EventArgs e)
{
validationInput(TextBox1);
Label1.Text = validationInput(TextBox1);// here it did not show in the Label
}
private string validationInput(TextBox tb)
{
int minute;
int input;
string msg;
input = Convert.ToInt32(tb.Text);
minute = Convert.ToInt32((Convert.ToDouble(input)/100 - Convert.ToDouble(input/100)) * 100);
msg = Convert.ToString(minute);
return msg;
}
Is there a simple way to validate it or how can I change my method?
Thank you very much.
...
Go to the complete details ...