function check_empty(a) { a = $(a); if (a.getValue().blank() && !a.disabled) { show_error_msg(errorMsgs.please_enter, new Array("#label#"), new Array(a.readAttribute("label")), a); return false } return true } function check_empty2(a) { a = $(a); if (a.getValue().blank() && !a.disabled) { show_error_msg(errorMsgs.please_enteryour, new Array("#label#"), new Array(a.readAttribute("label")), a); return false } return true } function check_value(a, b) { a = $(a); if (a.getValue() == b) { show_error_msg(errorMsgs.select_empty, new Array("#label#"), new Array(a.readAttribute("label")), a); return false } return true } function check_radio(a) { a = $(a); var b = false; $$("input[name = " + a.name + "]").each(function(c) { if (c.getValue() != null) { b = true; throw $break } }); if (!b) { show_error_msg(errorMsgs.select_empty, new Array("#label#"), new Array(a.readAttribute("label")), a) } return b } function check_email(b) { b = $(b); b.value = b.value.replace(/^\s+|\s+$/, ""); var c = b.getValue(); if (c == "") { return true } var a = new RegExp(/^\s*([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+\s*$/); if (!(a.test(c))) { show_error_msg(errorMsgs.invalid_format, new Array("#label#"), new Array(b.readAttribute("label")), b); return false } else { return true } } function check_english(b) { b = $(b); var c = b.getValue(); if (c == "") { return true } var a = new RegExp(/^([a-zA-Z0-9 -])*$/); if (!(a.test(c))) { show_error_msg(errorMsgs.invalid_format, new Array("#label#"), new Array(b.readAttribute("label")), b); return false } else { return true } } function check_email_suffix(b) { b = $(b); var c = b.getValue(); if (c == "") { return true } var a = new RegExp(/^([a-zA-Z0-9_\.\-])+$/); if (!(a.test(c))) { show_error_msg(errorMsgs.invalid_format, new Array("#label#"), new Array(b.readAttribute("label")), b); return false } else { return true } } function check_same(a, b) { a = $(a); if ($(b).getValue() != a.value) { show_error_msg(errorMsgs.same, new Array("#label#", "#label1#"), new Array(a.readAttribute("label"), $(b).readAttribute("label")), a); return false } return true } function check_duplicate(a, b) { a = $(a); if ($(b).getValue() == a.value) { show_error_msg(errorMsgs.duplicate, new Array("#label#", "#label1#"), new Array(a.readAttribute("label"), $(b).readAttribute("label")), a); return false } return true } function check_tel_duplicate(a, b) { a = $(a); if ($($(b).name + "Code").getValue() + "" + $(b).getValue() == $(a.name + "Code").getValue() + "" + a.value) { show_error_msg(errorMsgs.duplicate, new Array("#label#", "#label1#"), new Array(a.readAttribute("label"), $(b).readAttribute("label")), a); return false } return true } function check_date(b) { b = $(b); var c = $(b); var e = $(b.name.replace(/Day/, "Month")); var d = $(b.name.replace(/Day/, "Year")); if (c.getValue() == "") { show_error_msg(errorMsgs.select_empty, new Array("#label#"), new Array(b.readAttribute("label")), c); return false } if (e.getValue() == "") { show_error_msg_withRowName(errorMsgs.select_empty, new Array("#label#"), new Array(b.readAttribute("label")), e, b.name + "Row"); return false } if (d.getValue() == "") { show_error_msg_withRowName(errorMsgs.select_empty, new Array("#label#"), new Array(b.readAttribute("label")), d, b.name + "Row"); return false } var a = new Date(); a.setFullYear(d.getValue(), +e.getValue() - 1, c.getValue()); if (a.getFullYear() != d.getValue() || a.getMonth() != e.getValue() - 1 || a.getDate() != c.getValue()) { show_error_msg(errorMsgs.invalid_date, new Array("#label#"), new Array(b.readAttribute("label")), c); return false } return true } function check_age_min(b, c) { b = $(b); var a = $(b.name.replace(/DobDay/, "AgeTag")); if (parseInt(a.innerHTML) < c) { show_error_msg(errorMsgs.min_age, new Array("#label#", "#number#"), new Array(b.readAttribute("label"), c), b); return false } return true } function check_number(a) { a = $(a); if (a.getValue() == "") { return true } if (isNaN(a.getValue())) { show_error_msg(errorMsgs.nan, new Array("#label#"), new Array(a.readAttribute("label")), a); return false } return true } function check_year(a) { a = $(a); if (a.getValue() == "") { return true } if (!check_number(a)) { return false } else { var b = parseInt(a.getValue()); if (b < 1900 || b > 2100) { show_error_msg(errorMsgs.invalid_edition_format, new Array("#label#"), new Array(a.readAttribute("label")), a); return false } } return true } function check_tel_no(a) { a = $(a); if (a.getValue() == "") { return true } var b = null; if ($(a.name + "Code") != null) { b = $(a.name + "Code").getValue() } if ((b != null && isNaN(b)) || isNaN(a.value)) { show_error_msg(errorMsgs.nan, new Array("#label#"), new Array(a.readAttribute("label")), a); return false } if ((b == "852" || b == null) && a.value.length != 8) { show_error_msg(errorMsgs.number_equal, new Array("#label#", "#number#"), new Array(a.readAttribute("label"), 8), a); return false } return true } function check_id_format(a) { a = $(a); a.value = a.value.toUpperCase().replace(/^\s+|\s+$/, ""); var b = a.value; if (b == "") { return true } if (!validHKID(b)) { show_error_msg(errorMsgs.invalid_format, new Array("#label#"), new Array(a.readAttribute("label")), a); return false } return true } function validHKID(c) { var g = c.substring(c.length - 3); var f = g.charAt(1); var d = new RegExp(/^[a-zA-Z]{1,2}\d{6,7}\([a-zA-Z0-9]{1}\)$/g); if (!(d.test(c))) { return false } var k = 0; var j = 0; var h = 0; if (c.length == 10) { k = 58 * 9 } for (var e = c.length - 2; e > 1; e--) { var b = c.charAt(c.length - 2 - e); k += getDigitValue(b) * e } h = k % 11; var a = k; if (f == "A") { a = a + 10 } else { a = a + Number(f) } if (a % 11 != 0) { return false } return true } function getDigitValue(a) { if (a.charCodeAt(0) >= 65 && a.charCodeAt(0) <= 90) { return a.charCodeAt(0) - 55 } return Number(a) }
function check_size(b, a) {
    b = $(b);
    if (b.value.replace("\n", "<br/>").length > a) {
        show_error_msg(errorMsgs.string_max, new Array("#label#", "#number#"), new Array(b.readAttribute("label"), a), b);
        return false;
    }
    return true;
}
function check_actual_size(b, a) {
    b = $(b);
    if (b.value.length > a) {
        show_error_msg(errorMsgs.string_max, new Array("#label#", "#number#"), new Array(b.readAttribute("label"), a), b);
        return false;
    }
    return true;
}
   function check_password(b) { b = $(b); var a = new RegExp(/^[a-zA-Z0-9]{4,15}$/g); if (!a.test(b.value)) { show_error_msg(errorMsgs.InvalidPassword, new Array(), new Array(), b); return false } return true } function check_website(b) { b = $(b); if (b.getValue() == "") { return true } b.value = b.value.toLowerCase(); b.value = b.value.replace("http://", "").replace("https://", ""); var a = new RegExp(/^(http(s?):\/\/)?(www.)?(\w|-)+(\.(\w|-)+)*((\.[a-zA-Z]{2,3})|\.(aero|coop|info|museum|name))+(\/)?.*$/g); if (!a.test(b.value)) { show_error_msg(errorMsgs.InvalidWebsite, new Array("#label#"), new Array(b.readAttribute("label")), b); return false } return true };
function check_empty_with_default_value(a,b) {
    a = $(a);
    if (a.hasClassName(b)) {
        show_error_msg(errorMsgs.please_enter, new Array("#label#"), new Array(a.readAttribute("label")), a);
        return false;
    }
    return true;
}
