var finMesg = "Please correct following errors...\n"; var finCount = 0; var finGotErr = "N"; var varControl; function notGreterThanToday(a) { var b = new Date(); var c = b.getFullYear(); var d = (b.getMonth()) + 1; var e = b.getDate(); var f = a; var g = new Array(3); g = f.split("/"); var h = g[2]; var i = g[1]; var j = g[0]; if (h == c) { if (i > d) { return false } else if (i == d) { if (j > e) { return false } } } else if (h > c) { return false } return true } function istodaysDate(a) { var b = new Date(); var c = b.getFullYear(); var d = (b.getMonth()) + 1; var e = b.getDate(); var f = a; var g = new Array(3); g = f.split("/"); var h = g[2]; var i = g[1]; var j = g[0]; if (h == c) { if (i != d) { return false } else if (i == d) { if (j == e) { return true } else { return false } } } else { return false } } function isEqualDate(a, b) { var c = a; var d = new Array(3); d = c.split("/"); var e = d[2]; var f = d[1]; var g = d[0]; var h = b; var i = new Array(3); i = h.split("/"); var j = i[2]; var k = i[0]; var l = i[1]; if (e == j) { if (f != l) { return false } else if (f == l) { if (g == k) { return true } else { return false } } } else { return false } } function notSmallerThanToday(a) { var b = new Date(); var c = b.getFullYear(); var d = (b.getMonth()) + 1; var e = b.getDate(); var f = a; var g = new Array(3); g = f.split("/"); var h = g[2]; var i = g[1]; var j = g[0]; if (h == c) { if (i < d) { return false } else if (i == d) { if (j < e) { return false } } } else if (h < c) { return false } return true } function CompareDates(a, b) { var c = new Array(3); c = a.split("/"); var d = parseFloat(c[2]); var e = parseFloat(c[1]); var f = parseFloat(c[0]); var g = b; var h = new Array(3); h = g.split("/"); var i = parseFloat(h[2]); var j = parseFloat(h[1]); var k = parseFloat(h[0]); if (i == d) { if (j < e) { return false } else if (j == e) { if (k < f) { return false } } } else if (i < d) { return false } return true } function isvalidCurrency(a) { a = Math.round(parseFloat(a) * 100); a = a / 100; if (a == "0") { return false } a = a.toString(); invalidchrs = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\{\}\/\'\:\)\(\,\=\+\-\_\~\`\!\@\#\$\%\^\&\*\;\>\<\]\[ "; if (IsInCharacterSet(invalidchrs, a)) { return false } atpos = a.indexOf(".", 0); if (atpos == 0 || a.indexOf("..", atpos) != -1) return false; if (a.indexOf(".", atpos + 1) != -1) return false; dotpos = a.indexOf(".", atpos); if (dotpos != -1) { if (dotpos + 2 < a.length - 1) return false } return true } function checkSelectBox(a, b) { var c = a.selectedIndex; var d = a[c].value; if (d == b) return false; else return true } function checkPassword(a) { if (a[0] == a[1]) return true; else return false } function IsValidTime(a) { var b = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/; var c = a.match(b); if (c == null) { return false } hour = c[1]; minute = c[2]; second = c[4]; ampm = c[6]; if (second == "") { second = null } if (ampm == "") { ampm = null } if (hour < 0 || hour > 23) { return false } if (hour <= 12 && ampm == null) { return false } if (hour > 12 && ampm != null) { return false } if (minute < 0 || minute > 59) { return false } if (second != null && (second < 0 || second > 59)) { return false } return true } function checkDate(b) { for (a = 0; a < b.length; a++) { var c = b[a][0]; var d = b[a][1]; var e = b[a][2]; var i = c.selectedIndex; var f = c[i].value; var j = d.selectedIndex; var g = d[j].value; var k = e.selectedIndex; var h = e[k].value; if (h.length == 4 && Math.abs(h) <= 1800) { return false } if (f != 0 || g != 0 || eval(h) != 0) { if (f > 31 || g > 12 || f < 1 || g < 1 || h < 1) { alert("invalid date"); return false } else if ((g == 1 || g == 3 || g == 5 || g == 7 || g == 8 || g == 10 || g == 12) && (f > 31)) { alert("invalid day according to month"); return false } else if ((g == 4 || g == 6 || g == 9 || g == 11) && (f > 30)) { alert("invalid day according to month"); return false } else if (g == 2) { if (LeapYear(h) == true) { if (f > 29) { alert("invalid day"); return false } } else { if (f > 28) { alert("invalid day"); return false } } } } } return true } function LeapYear(a) { if (a % 100 == 0) { if (a % 400 == 0) { return true } } else { if ((a % 4) == 0) { return true } } return false } function checktxtDate(a, b) { var c = new Array(13); c[0] = " "; c[1] = "JAN"; c[2] = "FEB"; c[3] = "MAR"; c[4] = "APR"; c[5] = "MAY"; c[6] = "JUN"; c[7] = "JUL"; c[8] = "AUG"; c[9] = "SEP"; c[10] = "OCT"; c[11] = "NOV"; c[12] = "DEC"; var d = new Array("-", " ", "/", "."); var e = "notMatching"; for (vs = 0; vs < d.length; vs++) { if (a.value.indexOf(d[vs]) != -1) { e = a.value.split(d[vs]); break } } if (e == "notMatching" || e.length != 3) { return false } else if (b == "dd/mm/yy" || b == "dd/mm/yyyy" || b == "dd-mm-yyyy" || b == "dd-mm-yy" || b == "dd.mm.yy" || b == "dd.mm.yyyy") { intday = e[0]; intMonth = e[1]; intyear = e[2]; if (intyear.length == 3 || intyear.length == 1) { return false } if (intyear.length == 4 && Math.abs(intyear) <= 1800) { return false } if (intyear.length != 4 && b == "dd/mm/yyyy") { return false } if (isNaN(intMonth)) { var f = false; for (month = 1; month < c.length; month++) { if (c[month] == intMonth.toUpperCase()) { intMonth = month; f = true; break } } if (!f) { return false } } } else if (b == "mm/dd/yy" || b == "mm/dd/yyyy" || b == "mm-dd-yy" || b == "mm-dd-yyyy" || b == "mm.dd.yy" || b == "mm.dd.yyyy") { intday = e[1]; intMonth = e[0]; intyear = e[2]; if (isNaN(intMonth)) { for (month = 1; month < c.length; month++) { if (c[month] == intMonth.toUpperCase()) { intMonth = month; break } } } } else if (b == "yy/mm/dd" || b == "yyyy/mm/dd" || b == "yy-mm-dd" || b == "yyyy-mm-dd" || b == "yy.mm.dd" || b == "yyyy.mm.dd") { intday = e[2]; intMonth = e[1]; intyear = e[0]; if (isNaN(intMonth)) { for (month = 1; month < c.length; month++) { if (c[month] == intMonth.toUpperCase()) { intMonth = month; break } } } } if (isNaN(intday) || isNaN(intyear)) { return false } if (eval(intday) != 0 || eval(intMonth) != 0 || eval(intyear) != 0) { if (intday > 31 || intMonth > 12 || intday < 1 || intMonth < 1 || intyear < 1) { return false } else if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31)) { return false } else if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30)) { return false } else if (intMonth == 2) { if (LeapYear(intyear)) { if (intday > 29) { return false } } else { if (intday > 28) { return false } } } } else { return false } return true } function IsValidTime(a) { var b = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/; var c = a.match(b); if (c == null) { return false } hour = c[1]; minute = c[2]; second = c[4]; ampm = c[6]; if (second == "") { second = null } if (ampm == "") { ampm = null } if (hour < 0 || hour > 12) { return false } if (minute < 0 || minute > 59) { return false } if (second != null && (second < 0 || second > 59)) { return false } if (hour <= 12 && ampm == null) { return false } return true } function getAge(a, b) { var c = new Date(); var d = new Date(c.getYear(), c.getMonth(), c.getDate()); var e = c.getYear(); var f = c.getMonth(); var g = c.getDate(); if (b == 1) var h = new Date(a.substring(0, 4), a.substring(4, 6) - 1, a.substring(6, 8)); else if (b == 2) var h = new Date(a.substring(0, 2), a.substring(2, 4) - 1, a.substring(4, 6)); else if (b == 3) var h = new Date(a.substring(6, 10), a.substring(3, 5) - 1, a.substring(0, 2)); else if (b == 4) var h = new Date(a.substring(6, 8), a.substring(3, 5) - 1, a.substring(0, 2)); else return ''; var i = h.getYear(); i = i.toString(); if (i.length == 2) { i = "19" + i } if (i.length == 4 && Math.abs(i) <= 1800) { return '' } var j = h.getMonth(); var k = h.getDate(); yearAge = e - i; if (f >= j) var l = f - j; else { yearAge--; var l = 12 + f - j } if (g >= k) var m = g - k; else { l--; var m = 31 + g - k; if (l < 0) { l = 11; yearAge-- } } return yearAge + '.' + l } function Trim(s) { if (s != "") { while ((s.substring(0, 1) == ' ') || (s.substring(0, 1) == '\n') || (s.substring(0, 1) == '\r')) { s = s.substring(1, s.length) } while ((s.substring(s.length - 1, s.length) == ' ') || (s.substring(s.length - 1, s.length) == '\n') || (s.substring(s.length - 1, s.length) == '\r')) { s = s.substring(0, s.length - 1) } } return s } function checkFile(a) { var b = a; b = b.substring(b.length - 3, b.length); b = b.toLowerCase(); if (b == 'jpg' || b == 'gif' || b == 'bmp') { return true } } function checkDateFormat(a, b) { var c = new Array(13); c[0] = " "; c[1] = "JAN"; c[2] = "FEB"; c[3] = "MAR"; c[4] = "APR"; c[5] = "MAY"; c[6] = "JUN"; c[7] = "JUL"; c[8] = "AUG"; c[9] = "SEP"; c[10] = "OCT"; c[11] = "NOV"; c[12] = "DEC"; var d = new Array("-", " ", "/", "."); var e = "notMatching"; for (vs = 0; vs < d.length; vs++) { if (a.value.indexOf(d[vs]) != -1) { e = a.value.split(d[vs]); break } } if (e == "notMatching" || e.length != 3) { return false } else if (b == "dd/mm/yyyy" || b == "dd-mm-yyyy" || b == "dd.mm.yyyy") { intday = e[0]; intMonth = e[1]; intyear = e[2]; if (intyear.length == 3 || intyear.length == 1 || intyear.length == 2) { return false } if (intyear < 1800) { return false } if (isNaN(intMonth)) { var f = false; for (month = 1; month < c.length; month++) { if (c[month] == intMonth.toUpperCase()) { intMonth = month; f = true; break } } if (!f) { return false } } } else if (b == "mm/dd/yyyy" || b == "mm-dd-yyyy" || b == "mm.dd.yyyy") { intday = e[1]; intMonth = e[0]; intyear = e[2]; if (isNaN(intMonth)) { for (month = 1; month < c.length; month++) { if (c[month] == intMonth.toUpperCase()) { intMonth = month; break } } } } else if (b == "yyyy/mm/dd" || b == "yyyy-mm-dd" || b == "yyyy.mm.dd") { intday = e[2]; intMonth = e[1]; intyear = e[0]; if (isNaN(intMonth)) { for (month = 1; month < c.length; month++) { if (c[month] == intMonth.toUpperCase()) { intMonth = month; break } } } } if (isNaN(intday) || isNaN(intyear)) { return false } if (eval(intday) != 0 || eval(intMonth) != 0 || eval(intyear) != 0) { if (intday > 31 || intMonth > 12 || intday < 1 || intMonth < 1 || intyear < 1) { return false } else if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31)) { return false } else if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30)) { return false } else if (intMonth == 2) { if (LeapYear(intyear)) { if (intday > 29) { return false } } else { if (intday > 28) { return false } } } } else { return false } return true } function ValidTime(a) { var b = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/; var c = a.match(b); if (c == null) { return false } hour = c[1]; minute = c[2]; second = c[4]; ampm = c[6]; if (second == "") { second = null } if (ampm == "") { ampm = null } if (hour < 0 || hour > 12) { return false } if (minute < 0 || minute > 59) { return false } if (second != null && (second < 0 || second > 59)) { return false } if (hour <= 12 && ampm == null) { return false } return true } function CompareUserDates(a, b) { var c = new Array(3); c = a.split("/"); var d = c[2]; var e = c[1]; var f = c[0]; var g = b; var h = new Array(3); h = g.split("/"); var i = h[2]; var j = h[1]; var k = h[0]; if (i == d) { if (j < e) { return false } else if (j == e) { if (k < f) { return false } } } else if (i < d) { return false } return true } function validateMe(a, b, c) { finMesg = ""; var d = finCount; var e = finMesg; var f = finGotErr; var g = 0; var h = new Array(2); for (k = 0; k < a.length; k++) { var i = a[k][0]; var j = a[k][1]; var l = a[k][2]; var m = a[k][3]; if (m == "CompareDates") { var n; var o; var p; n = i.split("|"); o = n[0]; p = n[1]; if ((o.length) != 0 && (p.length) != 0) { var q = new Array(3); q = o.split("/"); var r = q[2]; if (r.length == 4 && Math.abs(r) <= 1800) { e = e + '<li>' + "Year of the date should be greater than 1800" + "<br/>"; f = "Y" } else { q = p.split("/"); var r = q[2]; if (r.length == 4 && Math.abs(r) <= 1800) { e = e + '<li>' + "Year of the date should be greater than 1800" + "<br/>"; f = "Y" } else { if (!CompareDates(o, p)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } } } else if (m == "CompareValues") { var n; var s; var t; n = i.split("|"); s = n[0]; t = n[1]; if ((!isNaN(s)) && (!isNaN(t))) { if (Math.abs(s) > Math.abs(t)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (m == "GreaterThanOREqual") { var n; var s; var t; n = i.split("|"); s = n[0]; t = n[1]; if ((!isNaN(s)) && (!isNaN(t))) { if (Math.abs(s) < Math.abs(t)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (m == "CompareValuesWithNotAllowEqual") { var n; var s; var t; n = i.split("|"); s = n[0]; t = n[1]; if ((!isNaN(s)) && (!isNaN(t))) { if (!(Math.abs(s) < Math.abs(t))) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (m == "GreaterThan") { var n; var s; var t; n = i.split("|"); s = n[0]; t = n[1]; if ((!isNaN(s)) && (!isNaN(t))) { if (!(Math.abs(s) > Math.abs(t))) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (m == "GreaterThanZero") { var s; s = i; if ((!isNaN(s))) { if (!(s > 0)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (m == "GreaterEqualThanZero") { var s; s = i; if ((!isNaN(s))) { if (!(s >= 0)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (m == "EqualValues") { var n; var s; var t; n = i.split("|"); s = n[0]; t = n[1]; if ((!isNaN(s)) && (!isNaN(t))) { if (Math.abs(s) != Math.abs(t)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (m == "PasswordConPassword") { var n; var s; var t; n = i.split("|"); s = n[0].value; t = n[1].value; if (s != t) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (m == "file") { if (Trim(i.value) != "") { if (!checkFile(i.value)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (m == "PrimaryKey") { var n; n = i.split("|"); for (z = 0; z < n.length; z++) { w = eval(n[z]).value; if (!IsEmpty(w)) { var u = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\{\}\/\'\:\)\(\,\=\+\_\~\`\!\@\#\$\%\^\&\*\;\>\<\.\]\[ "; if (IsInCharacterSet(u, w)) { f = "Y"; break } } else { f = "Y"; break } } if (f == "Y") { a[0][0] = eval(n[0]); e = e + '<li>' + l + "<br/>" } } else if (m == "date") { if (i.value.length != 0) { if (!checktxtDate(i, j)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (m == "textarea") { var v = i.value.length; if (v > j) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (m == "textarea/Empty") { var v = i.value.length; if (IsEmpty(i.value)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else if (v > j) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (m == "date/Empty") { if (IsEmpty(i.value)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else if (!checktxtDate(i, j)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (m == "password") { h[g] = i.value; if (g == 1 && !checkPassword(h)) { e = e + '<li>' + l + "<br/>"; f = "Y" } ++g } else if (m == "Names") { var w = (i.value).toUpperCase(); if (w == j) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (m == "text") { var w = i.value; var v = w.length; if (j == "Alpha") { if (!IsAlphabetic(w)) { e = e + '<li>' + l + "<br/>"; f = "Y"; break } } else if (j == "Time/Empty") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { if (!IsValidTime(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "NoGreaterDate/Empty") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { var q = new Array(); q = w.split("/"); if (q.length == 3) { var r = q[2]; if (r.length == 4 && Math.abs(r) <= 1800) { e = e + '<li>' + "Year of the date should be greater than 1800" + "<br/>"; f = "Y" } else { if (!notGreterThanToday(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } } } else if (j == "NoGreaterDate") { var q = new Array(); q = w.split("/"); if (q.length == 3) { var r = q[2]; if (r.length == 4 && Math.abs(r) <= 1800) { e = e + '<li>' + "Year of the date should be greater than 1800" + "<br/>"; f = "Y" } else { if (!notGreterThanToday(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } } else if (j == "NoSmallerDate/Empty") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { if (!notSmallerThanToday(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "AlphaNumericOnly") { if (!IsAlphaNumeric(w)) { e = e + (++d) + ". " + l + "\n"; f = "Y" } } else if (j == "ContainsNumerichyphen") { var u = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\{\}\/\'\:\)\(\,\\=\+\_\~\`\"\!\@\#\$\%\^\&\*\;\>\<\]\[\?"; if (IsInCharacterSet(u, w)) { e = e + (++d) + ". " + l + "\n"; f = "Y" } } else if (j == "AlphaNumericOnly/Empty") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { if (!IsAlphaNumeric(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "Alpha/Empty") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { if (!IsAlphabetic(w)) { e = e + '<li>' + l + "<br/>"; f = "Y"; break } } } else if (j == "AlphaOnly/Empty/NoSpace") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { if (!IsAlphabetic(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "AlphaOnly/Empty/SingleSpace") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { if (!IsAlphabetic(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } if (w.indexOf('  ') > -1) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "AlphaOnly/SingleSpace") { if (!IsAlphabetic(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } if (w.indexOf('  ') > -1 || w.charAt(0) == ' ') { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (j == "URL") { if (v != 0) { var x = w.substring(0, 4); var y = w.indexOf(".."); var A = w.lastIndexOf("."); if (x != "www." || y > 1 || A >= v - 1) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "Empty") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (j == "NumericOnlyRoleMembers") { if (w != "NA" && w != "na" && w != "-") { if (!IsNumeric(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "NumericOnly") { if (!IsNumeric(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (j == "NumericOnly/Empty") { if (!IsEmpty(w)) { if (!IsNumeric(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (j == "IntegerOnly") { if (!IsEmpty(w)) { if (!IsInteger(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "IntegerOnly/Empty") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { if (!IsInteger(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "Email") { if (!IsEmpty(w)) { if (!IsValidEmail(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "Currency") { if (!IsEmpty(w)) { w = Math.round(parseFloat(w) * 100); w = w / 100; if (!isvalidCurrency(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "Currency/Empty") { if (!IsEmpty(w)) { w = Math.round(parseFloat(w) * 100); w = w / 100; if (!isvalidCurrency(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (j == "Time") { if (!IsEmpty(w)) { if (!IsValidTime(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "NoSpace") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { if (IsInCharacterSet(' ', w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "AlphaNumeric") { if (!IsAlphaNumeric(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (j == "AlphaOnly/Empty") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { if (!IsAlphabetic(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "AlphaOnly") { if (!IsAlphabetic(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (j == "SpecialCharacters") { var u = "{\}\:\=\+\_\~\`\!\@\#\$\%\^\&\*\;\>\<"; if (IsInCharacterSet(u, w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (j == "AlphaOnlyWithAdd/Empty") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { var u = "1234567890\{\}\:\=\_\~\`\!\@\#\$\%\^\&\*\;\>\<\]\["; if (IsInCharacterSet(u, w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "AlphaNumeric/Empty") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { if (!IsAlphaNumeric(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "ValidateAdmData/Empty") { if (IsEmpty(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } else { if (!IsAlphaNumeric(w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (j == "SchoolName/Empty") { if (w == "" || w.charAt(0) == " ") { e = e + '<li>' + l + "<br/>"; f = "Y" } else { var u = "\{\}\/\)\(\=\+\_\~\`\!\@\#\$\%\^\*\>\<\]\[\'\"\\"; if (IsInCharacterSet(u, w)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } } else if (m == "AtleastOne") { if (j == "AtLeastOneRequired") { var B = i; var C = B[0].value; var D = B[1].value; var E = B[2].value; if ((C == "" || C == "Last Name") && (D == "" || D == "First Name") && (E == "" || E == "Middle Name")) { e = e + '<li>' + l + "<br/>"; f = "Y" } } } else if (m == "Empty/Date/BirthDate") { var B = i; var F = B[0].value; var G = B[1].value; var H = "N"; if (G == "" || G.charAt(0) == " ") { e = e + '<li>' + l + "<br/>"; f = "Y"; H = "Y" } else if (!checktxtDate(B[1], j)) { e = e + '<li>' + l + "<br/>"; f = "Y"; H = "Y" } else if (H != "Y") { var I = new Array(3); I = F.split("/"); var J = eval(I[2]); var K = eval(I[1] - 1); var L = eval(I[0]); var M = new Array(3); M = G.split("/"); var N = eval(M[2]); var O = eval(M[1] - 1); var P = eval(M[0]); var Q = new Date(); Q.setFullYear(J); Q.setDate(L); Q.setMonth(K); var R = new Date(); R.setFullYear(N); R.setDate(P); R.setMonth(O); if (Q > R) { var S = 1000 * 60; var T = S * 60; var U = T * 24; var V = U * 365; var W = ((Q.getTime() - R.getTime()) / V); if (W <= 14.009) { var X = new Array(3); X = F.split("/"); var Y = X[2]; var Z = Y - 14; e = e + '<li>' + l + '<br/>Birth Date  should be less than or equal to ' + X[0] + '/' + X[1] + '/' + Z + '.' + "<br/>"; f = "Y" } } else { e = e + '<li>' + l + '<br/>Birth Date should be less than admission date.' + "<br/>"; f = "Y" } } } else if (m == "Empty/date/NoGreaterDate/WithinAcademicYear") { var B = i; var F = B[0].value; var ba = B[1].value; var bb = B[2].value; var H = "N"; var bc = "N"; if (IsEmpty(F)) { e = e + '<li>' + l + "<br/>"; f = "Y"; H = "Y" } else if (!checktxtDate(B[0], j)) { e = e + '<li>' + l + "<br/>"; f = "Y"; H = "Y" } else if (H != "Y") { var q = new Array(); q = F.split("/"); if (q.length == 3) { var r = q[2]; if (r.length == 4 && Math.abs(r) <= 1800) { e = e + '<li>' + l + "<br/>"; f = "Y"; bc = "Y" } else { if (!notGreterThanToday(F)) { e = e + '<li>' + l + "<br/>Admission Date should not be greter than todays date<br/>"; f = "Y"; bc = "Y" } else { if (CompareDates(F, bb)) { if (!CompareDates(ba, F)) { var bd = new Array(3); bd = ba.split("/"); var be = bd[2]; var bf = new Array(3); bf = bb.split("/"); var bg = bf[2]; e = e + '<li>' + l + '<br/>Admission Date should be greater than or equal to ' + ba + " for current academic year " + be + "-" + bg + "<br/>"; f = "Y" } } else { e = e + '<li>' + l + '<br/>Admission Date should be less than or equal to ' + bb + "<br/>"; f = "Y" } } } } } } else if (m == "select") { if (!checkSelectBox(i, j)) { e = e + '<li>' + l + "<br/>"; f = "Y" } } else if (m == "RegularExpression/NonEmpty") { if (i.type == "text") { var bh = new RegExp(j); var bi = i.value; if (bi.match(bh) == null) { f = 'Y'; e = e + '<li>' + l + "<br/>" } } } else if (m == "RegularExpression/Empty") { if (i.type == "text") { var bh = new RegExp(j); var bi = i.value; if (bi == null || bi == "") { return true } else { if (bi.match(bh) == null) { f = 'Y'; e = e + '<li>' + l + "<br/>" } } } } } if (f == "Y") { showValidationSummary(i, e); return false } return true } function showValidationSummary(a, b) { var c = ""; if (document.getElementById('popupTable')) { document.getElementById('popupTable').parentNode.removeChild(document.getElementById('popupTable')) } if (b.indexOf("<li>") > -1) { c = "<div style='text-align:center;'><div style='min-height:100px;text-align:center;'><ol style='text-align:left;'>" + b + "</ol></div><div style='width:100%;vertical-align:bottom;padding-left:100px;text-align:left'><input type='button' class='clAlertBut' value='OK' onclick='closeValidator();'></div></div>" } else { c = "<div style='text-align:center;'><div style='min-height:100px;text-align:center;'><ol style='text-align:left;'>" + b + "</ol></div><div style='width:100%;vertical-align:bottom;padding-left:100px;text-align:left'><input type='button' class='clAlertBut' value='OK' onclick='closeValidator();'></div></div>" } var d = document.createElement("table"); var e = document.createElement("tbody"); var f = document.createElement("div"); var g = document.createElement("div"); var h = document.createElement("tr"); var i = document.createElement("td"); var j = document.createElement("td"); var k = document.createElement("td"); var l = document.createElement("tr"); var m = document.createElement("td"); var n = document.createElement("td"); var o = document.createElement("td"); d.cellPadding = 0; d.cellSpacing = 0; d.className = 'clPopupTable'; h.vAlign = 'top'; h.style.height = "100%"; i.className = 'clPopupIcon'; m.className = 'clPopupIcon2'; f.className = 'clAlertImage'; j.className = 'clPopupMessage'; n.innerHTML = c; n.className = 'clPopupMessage2'; k.className = 'clPopupClose'; o.className = 'clPopupClose2'; g.className = 'clCloseImage'; g.innerHTML = '&nbsp;'; g.onclick = closeValidator; var p = document.createElement("div"); p.id = "popupTable"; p.className = 'clPopupTableHolder'; document.body.appendChild(p); p.appendChild(d); d.appendChild(e); e.appendChild(h); h.appendChild(i); i.appendChild(f); j.innerHTML = "<strong>Please correct following errors...</strong>"; h.appendChild(j); h.appendChild(k); k.appendChild(g); e.appendChild(l); m.innerHTML = "&nbsp;"; l.appendChild(m); l.appendChild(n); o.innerHTML = "&nbsp;"; l.appendChild(o); d.style.left = (getBrowserWidth() - ((document.documentElement.scrollLeft + d.offsetWidth) / 2)) / 2 + 'px'; d.style.top = (getBrowserHeight() - (d.offsetHeight)) / 2 + 'px' } function getBrowserWidth() { if (window.innerWidth) return window.innerWidth; else if (document.body.clientWidth) return document.body.clientWidth; else return -1 } function getBrowserHeight() { return (window.innerHeight ? window.innerHeight : document.documentElement.clientHeight) } function getBodyHeight() { if (document.body.clientHeight) return document.body.clientHeight; else return -1 } function ShowConfirm(a, b) { varControl = a; b = "<div style='text-align:center;'><div style='min-height:100px;text-align:center;'><ol style='text-align:left;margin-left:0px;'>" + b + "</ol></div><div style='width:100%;vertical-align:bottom;padding-left:55px;text-align:left'><input type='button' class='clAlertBut' value='Yes' onclick='SetOkClick(varControl);'> &nbsp; <input type='button' class='clAlertBut' value='No' onclick='closeValidator();'></div></div>"; if (document.getElementById('popupTable')) { document.getElementById('popupTable').parentNode.removeChild(document.getElementById('popupTable')) } var c = document.createElement("table"); var d = document.createElement("tbody"); var e = document.createElement("div"); var f = document.createElement("div"); var g = document.createElement("tr"); var h = document.createElement("td"); var i = document.createElement("td"); var j = document.createElement("td"); var k = document.createElement("tr"); var l = document.createElement("td"); var m = document.createElement("td"); var n = document.createElement("td"); c.cellPadding = 0; c.cellSpacing = 0; c.className = 'clPopupTable'; g.vAlign = 'top'; g.style.height = "100%"; h.className = 'clPopupIcon'; l.className = 'clPopupIcon2'; e.className = 'clAlertImage'; i.className = 'clPopupMessage'; m.innerHTML = b; m.className = 'clPopupMessage2'; j.className = 'clPopupClose'; n.className = 'clPopupClose2'; f.className = 'clCloseImage'; f.onclick = closeValidator; var o = document.createElement("div"); o.id = "popupTable"; o.className = 'clPopupTableHolder'; document.body.appendChild(o); o.appendChild(c); c.appendChild(d); d.appendChild(g); g.appendChild(h); h.appendChild(e); i.innerHTML = "<strong>Confirm</strong>"; g.appendChild(i); g.appendChild(j); j.appendChild(f); d.appendChild(k); l.innerHTML = "&nbsp;"; k.appendChild(l); k.appendChild(m); n.innerHTML = "&nbsp;"; k.appendChild(n); c.style.left = (getBrowserWidth() - ((document.documentElement.scrollLeft + c.offsetWidth) / 2)) / 2 + 'px'; c.style.top = (getBrowserHeight() - (c.offsetHeight)) / 2 + 'px' } function SetOkClick(a) { closeValidator(); varResult = "Y"; __doPostBack(a) } function showValidator(a, b) { if (document.getElementById('popupTable')) { document.getElementById('popupTable').parentNode.removeChild(document.getElementById('popupTable')) } var c = document.createElement("tbody"); var d = document.createElement("tr"); var e = document.createElement("td"); var f = document.createElement("table"); var g = document.createElement("tbody"); var h = document.createElement("tr"); var i = document.createElement("td"); var j = document.createElement("td"); var k = document.createElement("table"); var l = document.createElement("td"); var m = document.createElement("div"); var n = document.createElement("div"); var o = document.createElement("div"); var p = document.createElement("td"); k.id = "popupTable"; k.cellPadding = 0; k.cellSpacing = 0; k.border = 0; k.width = "200px"; k.style.zIndex = '1001'; k.style.position = 'absolute'; var q = a.offsetLeft; var r = a.offsetParent; while (r != null) { q += r.offsetLeft; r = r.offsetParent } var s = a.offsetTop; var r = a.offsetParent; while (r != null) { s += r.offsetTop; r = r.offsetParent } k.style.left = q + a.offsetWidth; k.style.top = s; d.vAlign = 'top'; d.style.height = "100%"; e.width = 20; e.align = "right"; e.style.height = "100%"; e.style.verticalAlign = "top"; f.cellPadding = 0; f.cellSpacing = 0; f.border = 0; f.style.height = "100%"; l.align = "right"; l.vAlign = "top"; l.style.fontSize = "1px"; l.style.paddingTop = "8px"; m.border = 0; m.className = 'clArrowImage'; i.width = 20; i.style.borderTop = "1px solid black"; i.style.borderLeft = "1px solid black"; i.style.borderBottom = "1px solid black"; i.style.padding = "5px"; i.style.backgroundColor = 'LemonChiffon'; n.className = 'clAlertImage'; p.style.backgroundColor = 'LemonChiffon'; p.style.fontFamily = 'verdana'; p.style.fontSize = '10px'; p.style.padding = "5px"; p.style.borderTop = "1px solid black"; p.style.borderBottom = "1px solid black"; p.width = '100%'; p.innerHTML = b; j.style.borderTop = "1px solid black"; j.style.borderRight = "1px solid black"; j.style.borderBottom = "1px solid black"; j.style.backgroundColor = 'lemonchiffon'; j.style.verticalAlign = 'top'; j.style.textAlign = 'right'; j.style.padding = '2px'; o.className = 'clCloseImage'; o.onclick = closeValidator; a.parentNode.appendChild(k); k.appendChild(c); c.appendChild(d); d.appendChild(e); e.appendChild(f); f.appendChild(g); g.appendChild(h); h.appendChild(l); l.appendChild(m); d.appendChild(i); i.appendChild(n); d.appendChild(p); d.appendChild(j); j.appendChild(o) } function closeValidator() { document.getElementById('popupTable').parentNode.removeChild(document.getElementById('popupTable')) } function IsEmpty(a) { var b = new RegExp(/\S/g); a = a.replace(/^\s+|\s+$/g, ""); return !b.test(a) } function IsAlphabetic(a) { if (IsEmpty(a)) return true; var b = new RegExp(/^[a-zA-Z\-\(\)\.\,\?\|\\~\\\\ ]+$/); return b.test(a) } function IsAlphaNumeric(a) { if (IsEmpty(a)) return true; var b = new RegExp(/^[a-zA-Z0-9\-\(\)\.\,\?\|\\~\\\\ ]+$/); return b.test(a) } function IsInteger(a) { if (IsEmpty(a)) return true; var b = new RegExp(/^[0-9]+$/); return b.test(a) } function IsNumeric(a) { if (IsEmpty(a)) return true; var b = new RegExp(/^[0-9.]+$/); return b.test(a) } function IsInCharacterSet(a, b) { var c = false; for (l = 0; l < a.length; l++) { if (b.indexOf(a.charAt(l)) > -1) { c = true; break } } return c } function IsValidEmail(a) { var b = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; var c = new RegExp(b); return c.test(a) } function showAlert(a) { var b = ""; if (document.getElementById('popupTable')) { document.getElementById('popupTable').parentNode.removeChild(document.getElementById('popupTable')) } if (a.indexOf("<li>") > -1) { b = "<div style='text-align:center;'><div style='min-height:100px;text-align:center;'><ol style='text-align:left;'>" + a + "</ol></div><div style='width:100%;vertical-align:bottom;padding-left:100px;text-align:left'><input type='button' class='clAlertBut' value='OK' onclick='closeValidator();'></div></div>" } else { b = "<div style='text-align:center;'><div style='min-height:100px;text-align:center;'><ol style='text-align:left;'>" + a + "</ol></div><div style='width:100%;vertical-align:bottom;padding-left:100px;text-align:left'><input type='button' class='clAlertBut' value='OK' onclick='closeValidator();'></div></div>" } var c = document.createElement("table"); var d = document.createElement("tbody"); var e = document.createElement("div"); var f = document.createElement("div"); var g = document.createElement("tr"); var h = document.createElement("td"); var i = document.createElement("td"); var j = document.createElement("td"); var k = document.createElement("tr"); var l = document.createElement("td"); var m = document.createElement("td"); var n = document.createElement("td"); c.cellPadding = 0; c.cellSpacing = 0; c.className = 'clPopupTable'; g.vAlign = 'top'; g.style.height = "100%"; h.className = 'clPopupIcon'; l.className = 'clPopupIcon2'; e.className = 'clAlertImage'; i.className = 'clPopupMessage'; m.innerHTML = b; m.className = 'clPopupMessage2'; j.className = 'clPopupClose'; n.className = 'clPopupClose2'; f.className = 'clCloseImage'; f.onclick = closeValidator; var o = document.createElement("div"); o.id = "popupTable"; o.className = 'clPopupTableHolder'; document.body.appendChild(o); o.appendChild(c); c.appendChild(d); d.appendChild(g); g.appendChild(h); h.appendChild(e); i.innerHTML = "<strong>Alert</strong>"; g.appendChild(i); g.appendChild(j); j.appendChild(f); d.appendChild(k); l.innerHTML = "&nbsp;"; k.appendChild(l); k.appendChild(m); n.innerHTML = "&nbsp;"; k.appendChild(n); c.style.left = (getBrowserWidth() - ((document.documentElement.scrollLeft + c.offsetWidth) / 2)) / 2 + 'px'; c.style.top = (getBrowserHeight() - (c.offsetHeight)) / 2 + 'px' }

//Funtions added for BithDate validation in Online Admissions
function ValidateAdmissionDate(Arr, DialogHeight, CallingControl) { var count; var message; var gotErr; var count = 0; var message = ""; var gotErr = ""; var passcount = 0; var PassArray = new Array(2); for (k = 0; k < Arr.length; k++) { var myElement = Arr[k][0]; var whatToDo = Arr[k][1]; var myMessage = Arr[k][2]; var elementType = Arr[k][3]; var myValue = myElement.value; if (whatToDo == "OAAlphaNumericAllowSpecial/Empty") { if (myValue == "" || myValue.charAt(0) == " ") { gotErr = "Y" } else { var invalidChars = "\{\}\:\)\(\,\-\=\+\_\~\"\!\@\#\$\%\^\&\*\;\>\<\]\[\?"; for (l = 0; l < invalidChars.length; l++) { if (myValue.indexOf(invalidChars.charAt(l)) > -1) { gotErr = "Y"; break } } } } else if (elementType == "Empty/Date/OABirthDate") { var elements = myElement; var dChkDate = elements[0].value; var TxtDOB = elements[1].value; var Err = "N"; if (TxtDOB == "" || TxtDOB.charAt(0) == " ") { gotErr = "Y"; Err = "Y" } else if (!checktxtDate(elements[1], whatToDo)) { gotErr = "Y"; Err = "Y" } else if (Err != "Y") { var oChkdate = new Array(3); oChkdate = dChkDate.split("/"); var AdmYY = eval(oChkdate[2]); var AdmMM = eval(oChkdate[1] - 1); var AdmDD = eval(oChkdate[0]); var odateBir = new Array(3); odateBir = TxtDOB.split("/"); var BirYY = eval(odateBir[2]); var BirMM = eval(odateBir[1] - 1); var BirDD = eval(odateBir[0]); var myDate = new Date(); myDate.setFullYear(AdmYY); myDate.setDate(AdmDD); myDate.setMonth(AdmMM); var MyDOB = new Date(); MyDOB.setFullYear(BirYY); MyDOB.setDate(BirDD); MyDOB.setMonth(BirMM); if (myDate > MyDOB) { var minutes = 1000 * 60; var hours = minutes * 60; var days = hours * 24; var years = days * 365; var diffYears = ((myDate.getTime() - MyDOB.getTime()) / years); if (diffYears <= 14.009) { var odateArr = new Array(3); odateArr = dChkDate.split("/"); var ChkDateYY = odateArr[2]; var BirthYY = ChkDateYY - 14; gotErr = "Y" } } else { gotErr = "Y" } } } } if (gotErr == "Y") { message = '<li>' + myMessage + "</li>"; showValidationSummary(myElement, message); return false } return true }
//
//Function for applying mask
//
(function ($) { $.fn.applyMask = function (b) { $(b).each(function (a) { $(this).filter(function () { return $(this).val() == "" }).css({ 'color': '#c0c0c0', 'font-style': 'italic' }).val($(this).attr("title")); $(this).focus(function () { $(this).filter(function () { return $(this).val() == "" || $(this).val() == $(this).attr("title") }).css({ 'color': '#000000', 'font-style': 'normal' }).val("") }); $(this).blur(function () { $(this).filter(function () { return $(this).val() == "" }).css({ 'color': '#c0c0c0', 'font-style': 'italic' }).val($(this).attr("title")) }) }) } })(jQuery);


