Aspx Form
Javascript Function For Check validate time inserted or not

function CheckTime(Control) {
var txtBreakdownTime = document.getElementById(“”);
var ddlAMPM = document.getElementById(“”);
if (txtBreakdownTime != null && ddlAMPM != null) {
var BreakdownTime = txtBreakdownTime.value;
var HourNMinute = new Array();
HourNMinute = BreakdownTime.split(‘:’);
if (parseInt(HourNMinute[0]) > 12) {
alert(“Invalid Time Entry.”);
Control.focus();
}
if (parseInt(HourNMinute[1]) > 59) {
alert(“Invalid Time Entry.”);
Control.focus();
}
if (parseInt(HourNMinute[0]) == 12 && parseInt(HourNMinute[1]) > 0 && ddlAMPM.value == “PM”) {
alert(“Invalid Time Entry.”);
ddlAMPM.value = “AM”;
Control.focus();
}
}
——————————————————————

—————————————————————-
CS Page

DateTime StoppedAt;
String Start = txtDate.Text.Trim() + ” ” + txtBreakdownTime.Text.Trim() + “:00 ” + ddlAMPM.Value.Trim();
if (DateTime.TryParse(Start, out StoppedAt) == true)
{
StoppedAt = Convert.ToDateTime(Start);
sl.Add(“StoppedAt”, StoppedAt);
}

Advertisements