//------------------------------------------------------------------------------------------------------------------------------------
/*
This method is used to Check whether entered character is character or not
*/
//------------------------------------------------------------------------------------------------------------------------------------
function CheckIsCharacter(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode <> 90) && (charCode <> 122)) {
alert("This field accepts alphabets only.");
return false
}
return true
}
//------------------------------------------------------------------------------------------------------------------------------------
/*
This method is used to Check whether entered character is numeric or not
*/
//------------------------------------------------------------------------------------------------------------------------------------
function CheckNumericValue(e)
{
var key = e.which ? e.which : e.keyCode;;
if((key >=48 && key <= 57) || key == 58) { return true; } else { return false; } } //------------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------------ /* This method is used to Check whether entered character is numeric or not */ //------------------------------------------------------------------------------------------------------------------------------------ function CheckNumericValueWithoutColon(e) { var key = e.which ? e.which : e.keyCode;; if(key >=48 && key <= 57) { return true; } else { return false; } } //------------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------------ /* This method is used to Check whether entered Time is valid or Invalid */ //------------------------------------------------------------------------------------------------------------------------------------ function CheckTime(obj) { var txt = document.getElementById(obj); var val = txt.value; if (val != "") { if (parseInt(val.indexOf(':')) == 0) { alert('Invalid Entry..'); txt.value = ""; return false; } else if(parseInt(val.indexOf(':')) == -1) { if(val.length > 2)
{
alert('Please Enter Time in the HH:MM format');
txt.focus();
txt.value = "";
return false;
}
else
{
if((parseInt(val) <> 23))
{
alert('Please Enter Hours in the range of [0 - 23]');
txt.focus();
txt.value = "";
return false;
}
else
{
if(parseInt(val.length) == 1)
{
var Hrs = "0" + val + ":" + "00";
txt.value = Hrs;
}
else
{
txt.value = val + ":" + "00";
}
}
}
}
else
{
if(parseInt(val.indexOf(':')) != 0)
{
var strSpilt = val.split(':');
var hrslength = strSpilt[0].length;
var minslength = strSpilt[1].length;
var strHours;
var strMins;
if((parseInt(strSpilt[0]) <> 23))
{
alert('Hours should not be in the range of [0 - 23]');
txt.focus();
txt.value = "";
return false;
}
if(strSpilt[1] != "")
{
if((parseInt(strSpilt[1]) <> 59))
{
alert('Minutes should be in the range of [0 - 59]');
txt.value = val.substring(0,(parseInt(val.indexOf(':')) + 1));
txt.focus();
return false;
}
}
else
{
alert('Please Enter Minutes in the range of [0 - 59]');
txt.focus();
return false;
}
if(parseInt(hrslength) > 0)
{
if(parseInt(hrslength) == 1)
{
strHours = "0" + strSpilt[0];
}
else
{
strHours = strSpilt[0];
}
}
if(parseInt(minslength) > 0)
{
if(parseInt(minslength) == 1)
{
strMins = "0" + strSpilt[1];
}
else
{
strMins = strSpilt[1];
}
}
txt.value = strHours + ":" + strMins;
}
}
}
return txt.value;
}
//------------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------
/*
This method is used to Check whether entered FromTime is valid or Invalid
*/
//------------------------------------------------------------------------------------------------------------------------------------
function CheckFromTime(Grid,index)
{
var grid = document.getElementById(Grid);
var input = grid.rows[index + 1].getElementsByTagName("input");
var FromTimeID;
var ToTimeID;
for(var i = 0;i<=input.length-1;i++) { if(input[i].type != null) { if(input[i].type =="text") { var ids = input[i].id.substring(input[i].id.lastIndexOf('_') + 1); if(ids == "GrdtxtFromTime") { FromTimeID = input[i].id; } if(ids == "GrdtxtToTime") { ToTimeID = input[i].id; } } } } var FromTime = CheckTime(FromTimeID); var ToTime = document.getElementById(ToTimeID); var ConvertFromTime = ConvertintoDateTime(FromTime); if(ToTime.value != "") { var ConvertToTime = ConvertintoDateTime(ToTime.value); if(Date.parse(ConvertFromTime) >= Date.parse(ConvertToTime))
{
alert('From Time should be less than To Time');
document.getElementById(FromTimeID).focus();
document.getElementById(FromTimeID).value = "";
return false;
}
}
}
//------------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------
/*
This method is used to Check whether entered ToTime is valid or Invalid
*/
//------------------------------------------------------------------------------------------------------------------------------------
function CheckToTime(Grid,index)
{
var grid = document.getElementById(Grid);
var input = grid.rows[index + 1].getElementsByTagName("input");
var FromTimeID;
var ToTimeID;
for(var i = 0;i<=input.length-1;i++) { if(input[i].type != null) { if(input[i].type =="text") { var ids = input[i].id.substring(input[i].id.lastIndexOf('_') + 1); if(ids == "GrdtxtFromTime") { FromTimeID = input[i].id; } if(ids == "GrdtxtToTime") { ToTimeID = input[i].id; } } } } var FromTime = document.getElementById(FromTimeID); if(FromTime.value != "") { var ToTime = CheckTime(ToTimeID); var ConvertToTime = ConvertintoDateTime(ToTime); var ConvertFromTime = ConvertintoDateTime(FromTime.value); if(ToTime != "") { if(Date.parse(ConvertToTime) <= Date.parse(ConvertFromTime)) { alert('To Time should be greater than From Time'); document.getElementById(ToTimeID).value = ""; return false; } } } else { //alert('Please Enter From Time first...'); document.getElementById(ToTimeID).value = ""; return false; } } //------------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------------ /* This method is used to Convert Time into DateTime */ //------------------------------------------------------------------------------------------------------------------------------------ function ConvertintoDateTime(Val) { var d1 = new Date(); var MM = d1.getMonth() + 1; var DD = d1.getDate(); var YYYY = d1.getFullYear(); var strDate = MM + '/' + DD + '/' + YYYY; var d2 = new Date(strDate + " " + Val); return d2; } //------------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------------ /* This method is used to Enable/Disable TextBoxes in a GridView based on checkbox checked */ //------------------------------------------------------------------------------------------------------------------------------------ function EnableCtrls(Grid,index) { var grid = document.getElementById(Grid); var input = grid.rows[index + 1].getElementsByTagName("input"); for(var i = 0;i<=input.length-1;i++) { if(input[i].type != null) { var chkflag; if(input[i].type =="checkbox") { chkflag = document.getElementById(input[i].id); } if(chkflag.checked == true) { if(input[i].type =="text") { document.getElementById(input[i].id).disabled = false; } } else { if(input[i].type =="text") { document.getElementById(input[i].id).value = ""; document.getElementById(input[i].id).disabled = true; } } } } } //------------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------------ /* This method is used to Enable/Disable TextBoxes in a GridView based on checkbox checked */ //------------------------------------------------------------------------------------------------------------------------------------ function CheckCases(Grid,index,str) { var grid = document.getElementById(Grid); var input = grid.rows[index + 1].getElementsByTagName("input"); var FollowUpCasesID; var NewCasesID; for(var i = 0;i<=input.length-1;i++) { if(input[i].type != null) { if(input[i].type =="text") { var ids = input[i].id.substring(input[i].id.lastIndexOf('_') + 1); if(ids == "GrdtxtNewCases") { NewCasesID = input[i].id; } if(ids == "GrdtxtFollowUpCases") { FollowUpCasesID = input[i].id; } } } } var followUpCases = document.getElementById(FollowUpCasesID); var NewCases = document.getElementById(NewCasesID); var tot = 0; var fpCases = 0; var NCases = 0; if (followUpCases.value != "") { tot = parseInt(tot) + parseInt(followUpCases.value); } if (NewCases.value != "") { tot = parseInt(tot) + parseInt(NewCases.value); } if(parseInt(tot) > 32)
{
alert('Total Cases should not exceed more than 32');
if(str == "FollowUpCases")
{
document.getElementById(FollowUpCasesID).value = "";
document.getElementById(FollowUpCasesID).focus();
}
if(str == "NewCases")
{
document.getElementById(NewCasesID).value = "";
document.getElementById(NewCasesID).focus();
}
return false;
}
}
//------------------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment