﻿/*
//###########################################################################################################
// Description : Client side Javascript page 
// Author :  JJL, SCS                   Date : 03 April 2009
// Copyright 2009 John Wiley and Sons Ltd
//-----------------------------------------------------------------------------------------------------------
// Change log:	Date        Reference		Author		Description
//-----------------------------------------------------------------------------------------------------------
//              06/04/2009  WO088.R01.P01   JJL,NCS     Condition added to check for password min. and max. length.
//              08/04/2009  WO088.R01.P02   JJL,NCS     Added isValidEmail()
//              24/07/2009  WO091.R01       JJL,NCS     Added ToggleDefault()
//              14/09/2009  WO091.R01.P05   TSL,NCS     Remove ValidateSendingDate()
//###########################################################################################################
*/

// 24/07/2009  WO091.R01  starts

function ValidatePageTitle(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtTitle")).value);
    if (((xx != "") && (xx.length < 2))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidateRequiredFieldsContentUpdate(source, args) {

    var xx1 = trim(document.getElementById(GetClientId("txtTitle")).value);
    var xx2 = trim(document.getElementById(GetClientId("ceContent")).value);

    if ((xx1 != "") && (xx2 != "")) {
        args.IsValid = true;
    }
    else {
        args.IsValid = false;
    }
}
function ValidateRequiredFieldsHomePageContentUpdate(source, args) {
    var xx1 = trim(document.getElementById(GetClientId("ceContentColumn2")).value);
    var xx2 = trim(document.getElementById(GetClientId("ceContentColumn3")).value);

    if ((xx1 != "") && (xx2 != "")) {
        args.IsValid = true;
    }
    else {
        args.IsValid = false;
    }
}

function ToggleDefault(obj, defaultValue) {
    var x = trim(obj.value);
    if (x == "")
 
        obj.value = defaultValue;
    else if (x == defaultValue) 
        obj.value = "";
}

function changeVal(obj, defaultValue) {
    var x = trim(obj.value);

    if (x == defaultValue) {
        obj.value = "";
    }
}

function ValidateAdminSearchTerm(source, args) {
    var xx1 = trim(document.getElementById(GetClientId("txtSearchKey")).value).toLowerCase();
    var xx2 = document.getElementById(GetClientId("ddlFilter")).value.toLowerCase();
    var pnlResult = document.getElementById(GetClientId("pnlResults"));

    if ((((xx1.length == 0) || (xx1 == "enter search term")) && (xx2 == "all")) || (xx1.length > 0)) {
        args.IsValid = true;
        pnlResult.style.visibility = "visible";
    }
    else {
        args.IsValid = false;
        pnlResult.style.visibility = "hidden";
    }
}

function ValidateSearchTerm(source, args) {
    var x = document.getElementById(GetClientId("txtSearchKey")).value.toLowerCase();
    var pnlResult = document.getElementById(GetClientId("pnlResults"));
    
    if ((x.length == 0) || (x=="enter search term")) {
        args.IsValid = false;
        pnlResult.style.visibility = "hidden";
    }
    else {
        args.IsValid = true;
        pnlResult.style.visibility = "visible";
    }
}

function trim(str) {
    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
function ValidateRegistrationRequiredFields(source, args) {
    var x1 = trim(document.getElementById(GetClientId("txtcustno")).value);
    var x2 = trim(document.getElementById(GetClientId("txtusername")).value);
    var x3 = trim(document.getElementById(GetClientId("txtpassword")).value);
    var x4 = trim(document.getElementById(GetClientId("txtpassword1")).value);
    var x5 = trim(document.getElementById(GetClientId("txtemailaddress")).value);

    if ((x1 != "") && (x2 != "") && (x3 != "") && (x4 != "") && (x5 != "")) {
        args.IsValid = true;
    }
    else {
        args.IsValid = false;
    }
}
function ValidateInvalidText(source, args) {
    var x1 = document.getElementById(GetClientId("txtcustno")).value;
    var x2 = document.getElementById(GetClientId("txtusername")).value;
    var x3 = document.getElementById(GetClientId("txtpassword")).value;
    var x4 = document.getElementById(GetClientId("txtpassword1")).value;
    var x5 = document.getElementById(GetClientId("txtemailaddress")).value;

    if (((x1.toLowerCase().match("content-type:") == null) && (x1.toLowerCase().match("multipart/alternative") == null) && (x1.toLowerCase().match("content-transfer-encoding") == null)) && ((x2.toLowerCase().match("content-type:") == null) && (x2.toLowerCase().match("multipart/alternative") == null) && (x2.toLowerCase().match("content-transfer-encoding") == null)) && ((x3.toLowerCase().match("content-type:") == null) && (x3.toLowerCase().match("multipart/alternative") == null) && (x3.toLowerCase().match("content-transfer-encoding") == null)) && ((x4.toLowerCase().match("content-type:") == null) && (x4.toLowerCase().match("multipart/alternative") == null) && (x4.toLowerCase().match("content-transfer-encoding") == null)) && ((x5.toLowerCase().match("content-type:") == null) && (x5.toLowerCase().match("multipart/alternative") == null) && (x5.toLowerCase().match("content-transfer-encoding") == null))) {
        args.IsValid = true;
    }
    else {
        args.IsValid = false;
    }
}

function Subscribe_ClientClick() {
    Page_ClientValidate();
    
    if (Page_IsValid) {
        return true;
    }
    else {
        return false;
    }
}

function RequiredFields_ClientValidate(source, args) {
    var txtJnlDiscount = document.getElementById(GetClientId("txtJnlDiscount"));
    var ddlPayCardType = document.getElementById(GetClientId("ddlPayCardType"));
    var ddlMonth = document.getElementById(GetClientId("ddlMonth"));
    var ddlYear = document.getElementById(GetClientId("ddlYear"));
    var txtPayCardVerification = document.getElementById(GetClientId("txtPayCardVerification"));
    var txtCourtesyTitle = document.getElementById(GetClientId("txtCourtesyTitle"));
    var txtFirstName = document.getElementById(GetClientId("txtFirstName"));
    var txtLastName = document.getElementById(GetClientId("txtLastName"));
    var txtDepartment = document.getElementById(GetClientId("txtDepartment"));
    var txtEstablishment = document.getElementById(GetClientId("txtEstablishment"));
    var txtStreet = document.getElementById(GetClientId("txtStreet"));
    var txtTown = document.getElementById(GetClientId("txtTown"));
    var txtState = document.getElementById(GetClientId("txtState"));
    var txtPostCode = document.getElementById(GetClientId("txtPostCode"));
    var ddlCountry = document.getElementById(GetClientId("ddlCountry"));
    var txtEmail = document.getElementById(GetClientId("txtemailaddress"));
    var txtEmailVerify = document.getElementById(GetClientId("txtemailaddress1"));
    var txtTelNo = document.getElementById(GetClientId("txtTelNo"));
    var txtFaxNo = document.getElementById(GetClientId("txtFaxNo"));
    var txtPayCustomerNo = document.getElementById(GetClientId("txtPayCustomerNo"));
    var txtPayCardNumber = document.getElementById(GetClientId("txtPayCardNumber"));
    var txtPayCardHolderName = document.getElementById(GetClientId("txtPayCardHolderName"));
    var txtVatNumber = document.getElementById(GetClientId("txtVatNumber"));
    var txtGstNumber = document.getElementById(GetClientId("txtGstNumber"));
    var radPayOrderType1 = document.getElementById(GetClientId("radPayOrderType1"));
    var radPayOrderType2 = document.getElementById(GetClientId("radPayOrderType2"));
    var radPayVatRegYes = document.getElementById(GetClientId("radPayVatRegYes"));
    var radPayGstRegYes = document.getElementById(GetClientId("radPayGstRegYes"));
    var divDiscountCodeAccepted = document.getElementById(GetClientId("divDiscountCodeAccepted"));
    var divDiscountCodeInvalid = document.getElementById(GetClientId("divDiscountCodeInvalid"));
    var hdnCountryRegion = document.getElementById(GetClientId("hdnCountryRegion"));

    //Trim entry fields
    txtPayCustomerNo.value = trim(txtPayCustomerNo.value);
    txtJnlDiscount.value = trim(txtJnlDiscount.value);
    txtPayCardNumber.value = trim(txtPayCardNumber.value);
    txtPayCardVerification.value = trim(txtPayCardVerification.value);
    txtPayCardHolderName.value = trim(txtPayCardHolderName.value);
    txtCourtesyTitle.value = trim(txtCourtesyTitle.value);
    txtFirstName.value = trim(txtFirstName.value);
    txtLastName.value = trim(txtLastName.value);
    txtDepartment.value = trim(txtDepartment.value);
    txtEstablishment.value = trim(txtEstablishment.value);
    txtStreet.value = trim(txtStreet.value);
    txtTown.value = trim(txtTown.value);
    txtState.value = trim(txtState.value);
    txtPostCode.value = trim(txtPostCode.value);
    txtEmail.value = trim(txtEmail.value);
    txtTelNo.value = trim(txtTelNo.value);
    txtFaxNo.value = trim(txtFaxNo.value);
    hdnCountryRegion.value = trim(hdnCountryRegion.value);
    if (txtVatNumber != null) txtVatNumber.value = trim(txtVatNumber.value);
    if (txtGstNumber != null) txtGstNumber.value = trim(txtGstNumber.value);
    
    if (ddlCountry.value == "" && ddlPayCardType.value == "" && txtPayCardVerification.value == "" &&
        txtPayCardNumber.value == "" && ddlMonth.value == "-1" && ddlYear.value == "-1" &&
        txtPayCardHolderName.value == "" && txtFirstName.value == "" && txtLastName.value == "" &&
        txtStreet.value == "" && txtTown.value == "" && txtState.value == "" &&
        txtPostCode.value == "" && txtEmail.value == "" && txtEmailVerify.value == "") {
        args.IsValid = false;
        document.getElementById(GetClientId("hdnMandatoryBlank")).value = "true";
    }
    else {
        document.getElementById(GetClientId("hdnMandatoryBlank")).value = "false";
        args.IsValid = true;
    }
}

function cvRequiredFieldEmailValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtemailaddress = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    if ((x == "false") && ((txtemailaddress == "") || (txtemailaddress.length < 4))) {
        args.IsValid = false;
    }
}


function cvRequiredFieldEmailConfirmValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtemailaddress1 = trim(document.getElementById(GetClientId("txtemailaddress1")).value);
    if ((x == "false") && ((txtemailaddress1 == "") || (txtemailaddress1.length < 4))) {
        args.IsValid = false;
    }
}

function cvRequiredFieldStateValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtState = trim(document.getElementById(GetClientId("txtState")).value);
    if ((x == "false") && (txtState == "")) {
        args.IsValid = false;
    }
}

function cvRequiredFieldPostCodeValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtPostCode = trim(document.getElementById(GetClientId("txtPostCode")).value);
    if ((x == "false") && (txtPostCode == "")) {
        args.IsValid = false;
    }
}

function cvRequiredFieldTownValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtTown = trim(document.getElementById(GetClientId("txtTown")).value);
    if ((x == "false") && (txtTown == "")) {
        args.IsValid = false;
    }
}

function cvRequiredFieldAddress1Validate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtStreet = trim(document.getElementById(GetClientId("txtStreet")).value);
    if ((x == "false") && (txtStreet == "")) {
        args.IsValid = false;
    }
}


function cvRequiredFieldLastNameValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtLastName = trim(document.getElementById(GetClientId("txtLastName")).value);
    if ((x == "false") && (txtLastName == "")) {
        args.IsValid = false;
    }
}

function cvRequiredFieldFirstNameValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtFirstName = trim(document.getElementById(GetClientId("txtFirstName")).value);
    if ((x == "false") && (txtFirstName == "")) {
        args.IsValid = false;
    }
}

function cvRequiredFieldCardCCV(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtPayCardVerification")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}
function cvRequiredFieldCountryValidate(source, args) {
    var xx = trim(document.getElementById(GetClientId("ddlCountry")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}
function cvRequiredFieldCardType(source, args) {
    var xx = trim(document.getElementById(GetClientId("ddlPayCardType")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}
function cvRequiredFieldCardExpiry(source, args) {
    var xx = trim(document.getElementById(GetClientId("ddlMonth")).value);
    var xx1 = trim(document.getElementById(GetClientId("ddlYear")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && ((xx == -1)||(xx1 == -1))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}
function CardVerificationMinimum_ClientValidate(source, args) {

    var txtPayCardVerification = trim(document.getElementById(GetClientId("txtPayCardVerification")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;

    if ((x == "false") && ((txtPayCardVerification == "") || (txtPayCardVerification.length < 3))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function DiscountCodeAlphanumeric_ClientValidate(source, args) {
    args.IsValid = true;

    var txtJnlDiscount = document.getElementById(GetClientId("txtJnlDiscount"));

    txtJnlDiscount.value = trim(txtJnlDiscount.value);

    if (txtJnlDiscount.value != "") {
        if (!isAlphaNumeric(txtJnlDiscount.value)) {
            args.IsValid = false;
        }
    }
}

function CardNumberAlphanumeric_ClientValidate(source, args) {
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtPayCardNumber = trim(document.getElementById(GetClientId("txtPayCardNumber")).value);

    if ((txtPayCardNumber.length > 0) && (!isAlphaNumeric(txtPayCardNumber))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function CardholderNameAlphanumeric_ClientValidate(source, args) {
    args.IsValid = true;

    var txtPayCardHolderName = document.getElementById(GetClientId("txtPayCardHolderName"));

    txtPayCardHolderName.value = trim(txtPayCardHolderName.value);

    if (txtPayCardHolderName.value != "") {
        if (!isAlphaNumericWithPunctuations(txtPayCardHolderName.value)) {
            args.IsValid = false;
        }
    }
}

function WileyRefInvalid_ClientValidate(source, args) {
    args.IsValid = true;

    var txtPayCustomerNo = document.getElementById(GetClientId("txtPayCustomerNo"));
    var radPayOrderType2 = document.getElementById(GetClientId("radPayOrderType2"));

    txtPayCustomerNo.value = trim(txtPayCustomerNo.value);

    if ((radPayOrderType2.checked && txtPayCustomerNo.value == "") || (radPayOrderType2.checked && txtPayCustomerNo.value != "" && isNaN(txtPayCustomerNo.value))) 
    {
            args.IsValid = false;
    }
}

function VatNumberInvalid_ClientValidate(source, args) 
{
    args.IsValid = true;

    var txtVatNumber = document.getElementById(GetClientId("txtVatNumber"));
    var radPayVatRegYes = document.getElementById(GetClientId("radPayVatRegYes"));
    var hdnCountryRegion = document.getElementById(GetClientId("hdnCountryRegion"));

    if (hdnCountryRegion.value == "EU") 
    {
        txtVatNumber.value = trim(txtVatNumber.value);

        if ((radPayVatRegYes.checked && txtVatNumber.value == "") || ((radPayVatRegYes.checked && txtVatNumber.value != "" && isNaN(txtVatNumber.value)))) 
        {
                args.IsValid = false;
        }
    }
}

function GstNumberInvalid_ClientValidate(source, args) {
    args.IsValid = true;

    var ddlCountry = document.getElementById(GetClientId("ddlCountry"));
    var txtGstNumber = document.getElementById(GetClientId("txtGstNumber"));
    var radPayGstRegYes = document.getElementById(GetClientId("radPayGstRegYes"));

    if (ddlCountry.options[ddlCountry.selectedIndex].text == "Australia" ||
        ddlCountry.options[ddlCountry.selectedIndex].text == "Canada") {
        txtGstNumber.value = trim(txtGstNumber.value);
        if ((radPayGstRegYes.checked && txtGstNumber.value == "") || (radPayGstRegYes.checked && txtGstNumber.value != "" && isNaN(txtGstNumber.value))) 
        {
                args.IsValid = false;
        }
    }
}

function CardExpiryInvalid_ClientValidate(source, args) {
    args.IsValid = true;

    var ddlMonth = document.getElementById(GetClientId("ddlMonth"));
    var ddlYear = document.getElementById(GetClientId("ddlYear"));

    var currentDate = new Date();
    var currYear = currentDate.getFullYear();
    var currMonth = currentDate.getMonth();

    if (ddlMonth.value != "-1" && ddlYear.value != "-1") {
        
        if (ddlMonth.value <= currMonth+1 &&
            ddlYear.value <= currYear) {
            args.IsValid = false;
        }
    }
}

function CardVerificationInvalid_ClientValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtPayCardVerification = trim(document.getElementById(GetClientId("txtPayCardVerification")).value);
    if ((x == "false") && (txtPayCardVerification.length >= 3) && (isNaN(txtPayCardVerification))) {
            args.IsValid = false;
        }
    }

function CardNumberVerificationMinimum_ClientValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtPayCardNumber = trim(document.getElementById(GetClientId("txtPayCardNumber")).value);
    if ((x == "false") && (txtPayCardNumber == "")) {
        args.IsValid = false;
    }
}
function CardHolderNameVerificationMinimum_ClientValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtPayCardHolderName = trim(document.getElementById(GetClientId("txtPayCardHolderName")).value);
    if ((x == "false") && (txtPayCardHolderName == "")) {
        args.IsValid = false;
    }
}



function ConfirmEmailInvalid_ClientValidate(source, args) {
    args.IsValid = true;

    var txtEmail1 = trim(document.getElementById(GetClientId("txtemailaddress1")).value);
    
    if ((txtEmail1.length >= 4) && (!isValidEmail(txtEmail1))) {
            args.IsValid = false;
        }
}


function EmailInvalid_ClientValidate(source, args) {
    args.IsValid = true;

    var txtEmail = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    
    if ((txtEmail.length >= 4) && (!isValidEmail(txtEmail))) {
            args.IsValid = false;
        }
}

function EmailMismatch_ClientValidate(source, args) {
    args.IsValid = true;

    var txtEmail = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    var txtEmailVerify = trim(document.getElementById(GetClientId("txtemailaddress1")).value);


    if ((txtEmail.length >= 4) && (txtEmailVerify.length >= 4) && isValidEmail(txtEmail) && (txtEmail != txtEmailVerify)) {
                args.IsValid = false;
    }
}

function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=350,height=450,left = 490,top = 262');");
}

function isAlphaNumericWithPunctuations(str) {
    var re = /[^a-zA-Z0-9 \.\?\!\:\;\-\_\#\%\|\&\*\+\~\^\<\>\=\@\(\)\[\]\'\"\/\,\{\}]/g;
    if (re.test(str)) return false;
    return true;
}

function isAlphaNumeric(str) {
    var re = /[^a-zA-Z0-9 ]/g;
    if (re.test(str)) return false;
    return true;
}

function CheckAmendSubscription() {
    Page_ClientValidate();

    if (Page_IsValid) {
        //Only execute when all client validation has done.
        var boolAdmin = document.getElementById(GetClientId("hdnMemberAdmin")).value.toLowerCase();
        if (boolAdmin == "false") {
            var t = document.getElementById(GetClientId("chkchgsub")).checked;
            if (!t) {
                var x = confirm("Do you want to also update your subscription information?");
                if (x) {
                    document.getElementById(GetClientId("chkchgsub")).checked = true;
                }
            }
        }
        return true;
    }
    else {
        return false;
    }
}

function ValidateRequiredFieldsMemberUpdate(source, args) {
    var xx1 = trim(document.getElementById(GetClientId("txtfirstname")).value);
    var xx2 = trim(document.getElementById(GetClientId("txtsurname")).value);
    var xx3 = trim(document.getElementById(GetClientId("txtaddress1")).value);
    var xx4 = trim(document.getElementById(GetClientId("txttown")).value);
    var xx5 = trim(document.getElementById(GetClientId("ddlCountry")).value);
    var xx6 = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    var xx7 = trim(document.getElementById(GetClientId("txtpassword")).value);
    var xx8 = trim(document.getElementById(GetClientId("txtpassword1")).value);
    var xx = document.getElementById(GetClientId("hdnMemberType")).value;

    if (xx == "e") {
        xx7 = "       ";
        xx8 = "       ";
    }
    if ((xx1 == "") && (xx2 == "") && (xx3 == "") && (xx4 == "") && (xx5 == 0) && (xx6 == "") && (xx7 == "") && (xx8 == "")) {
        document.getElementById(GetClientId("hdnMandatoryBlank")).value = "true";
        args.IsValid = false;
    }
    else {
        document.getElementById(GetClientId("hdnMandatoryBlank")).value = "false";
        args.IsValid = true;
    }
}

function ValidateMemberUpdateFirstname(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtfirstname")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x=="false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}


function ValidateMemberUpdateSurname(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtsurname")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidateMemberUpdateAddress1(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtaddress1")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidateMemberUpdateTown(source, args) {
    var xx = trim(document.getElementById(GetClientId("txttown")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidateMemberUpdateCountry(source, args) {
    var xx = trim(document.getElementById(GetClientId("ddlCountry")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == 0)) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidateMemberUpdateEmailLength(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && ((xx == "") ||(xx.length < 4))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidatePasswordLength(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtpassword")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && ((xx == "") || (xx.length < 6))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}


function ValidateConfirmPasswordLength(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtpassword1")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && ((xx == "") || (xx.length < 6))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}


function CheckEmail(source, args) {
    var x = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    var memID = trim(document.getElementById(GetClientId("hdnMemberId")).value);
    var postBody = "{email:'" + x + "', memberID:'" + memID + "'}";

    new Ajax.Request('/WebService/validators.asmx/ValidateMemberEmail',
	  {
	      postBody: postBody,
	      asynchronous: false,
	      method: 'post', contentType: 'application/json; charset=utf-8', dataType: "json",
	      onSuccess: function(transport) {
	          var json = transport.responseText.evalJSON(true);
	          var response = json.d;
	          if (response == 0) {
	              args.IsValid = true;
	          }
	          else {
	              args.IsValid = false;
	          }
	      },
	      onFailure: function() {
	          args.IsValid = false;
	      }
	  });
}


// 24/07/2009  WO091.R01  ends

function SetPageDefaultTrue()
{
       for(i = 0; i < document.forms[0].elements.length; i++)
        {
            elm = document.forms[0].elements[i];
            if (elm.type == "textarea") 
            {
               elm.value = ' ';
            }
        }
}
    
    
function checkMaxLen(txt,maxLen) 
{
        try
        {
            if(txt.value.length > (maxLen-1)) 
            {
                var cont = txt.value;
                txt.value = cont.substring(0,(maxLen -1));
                return false;
            };
         }
         catch(e)
         {}
}

function isValidEmail(txt_email) {
    var emailFilter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;    
    //var emailFilter = /^\w+([-+.!#$%&'*/=?^`{|}~]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)+$/;    
    
    return emailFilter.test(txt_email);
}


function ValidateEmail(source, args)
{
  // 08/04/2009   WO088.R01.P02   JJL,NCS    Added condition to validate email
  var x = trim(document.getElementById(GetClientId("txtemailaddress")).value);

  if ((x.length > 3) && (!isValidEmail(x))) {
      args.IsValid = false;
  }
  else {
      args.IsValid = true;
  }
}
function ValidatePassword(source, args)
{
  // 06/04/2009   WO088.R01.P01   JJL,NCS    Condition added to check for password min. and max. length.
  var x = trim(document.getElementById(GetClientId("txtpassword")).value);
  if ((x.length > 0) && (x.length < 6)) {
      args.IsValid = false;
  }
  else {
      args.IsValid = true;
  }
}


function ValidateConfirmEmail(source, args)
{
    // 08/04/2009   WO088.R01.P02   JJL,NCS    Added condition to validate email
    var x = trim(document.getElementById(GetClientId("txtemailaddress1")).value);
    if ((x.length > 0) && (!isValidEmail(x))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}


function ValidateConfirmPassword(source, args)
{
  // 06/04/2009   WO088.R01.P01   JJL,NCS    Condition added to check for password min. and max. length.
  var x = trim(document.getElementById(GetClientId("txtpassword1")).value);
  if ((x.length > 0) && (x.length < 6)) {
      args.IsValid = false;
  }
  else {
      args.IsValid = true;
  }
}

function ValidateCompareEmail(source, args)
{
  var e1 = document.getElementById(GetClientId("txtemailaddress")).value;
  var e2 = document.getElementById(GetClientId("txtemailaddress1")).value;
  if ((e1 != "") && (e2 != ""))
  {  
    args.IsValid = e1 == e2;
  }
  else
  {
  args.IsValid = true;
  }
}

function ValidateComparePassword(source, args)
{
  var p1 = trim(document.getElementById(GetClientId("txtpassword")).value);
  var p2 = trim(document.getElementById(GetClientId("txtpassword1")).value);
  if ((p1.length >= 6) && (p2.length >= 6))
  {  
    args.IsValid = p1 == p2;
  }
  else
  {
  args.IsValid = true;
  }
}

function ValidateTitle(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txttitle")).value != ""; 
}
function ValidateFirstname(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtfirstname")).value != ""; 
}
function ValidateLastname(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtlastname")).value != ""; 
}
function ValidateAddress1(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtaddress1")).value != ""; 
}

function ValidateAddress2(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtaddress2")).value != ""; 
}
function ValidatePostCode(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtpostcode")).value != ""; 
}

function ValidateTitle(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txttitle")).value != ""; 
}

function ValidateDescription(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtdescription")).value != "";
}
function ValidateChairpersonEmail(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail")).value != "";
}
function ValidateEmail1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail1")).value != "";
}
function ValidateEmail2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail2")).value != "";
}
function ValidateEmail3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail3")).value != "";
}
function ValidateEmail4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail4")).value != "";
}
function ValidateEmail5(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail5")).value != "";
}
function ValidateEmail6(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail6")).value != "";
}
function ValidateMemberTitle1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle1")).value != "";
}
function ValidateMemberTitle2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle2")).value != "";
}
function ValidateMemberTitle3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle3")).value != "";
}
function ValidateMemberTitle4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle4")).value != "";
}
function ValidateMemberTitle5(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle5")).value != "";
}
function ValidateMemberTitle6(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle6")).value != "";
}
function ValidateFirstName1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname1")).value != "";
}
function ValidateFirstName2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname2")).value != "";
}
function ValidateFirstName3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname3")).value != "";
}
function ValidateFirstName4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname4")).value != "";
}
function ValidateFirstName5(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname5")).value != "";
}
function ValidateFirstName6(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname6")).value != "";
}
function ValidateLastName1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname1")).value != "";
}
function ValidateLastName2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname2")).value != "";
}
function ValidateLastName3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname3")).value != "";
}
function ValidateLastName4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname4")).value != "";
}
function ValidateLastName5(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname5")).value != "";
}
function ValidateLastName6(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname6")).value != "";
}
function ValidatePTitle1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtptitle1")).value != "";
}
function ValidatePTitle2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtptitle2")).value != "";
}
function ValidatePTitle3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtptitle3")).value != "";
}
function ValidatePTitle4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtptitle4")).value != "";
}
function ValidateAbstract1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtabstract1")).value != "";
}
function ValidateAbstract2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtabstract2")).value != "";
}
function ValidateAbstract3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtabstract3")).value != "";
}
function ValidateAbstract4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtabstract4")).value != "";
}

function ValidateEmailTitleRequired(source, args) {
    //var emailTitle = document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_emailtitle").value;
    var emailTitle = document.getElementById(GetClientId("emailtitle")).value;
    //var chkCustomEmail = document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_chkCustomEmail").checked;
    var chkCustomEmail = document.getElementById(GetClientId("chkCustomEmail")).checked;
    if (emailTitle == ""  && chkCustomEmail)
    {
        args.IsValid = false;
    }
}
function ValidateEmailTitleMinimum(source, args) {
    var emailTitle = document.getElementById(GetClientId("emailtitle")).value;
    var chkCustomEmail = document.getElementById(GetClientId("chkCustomEmail")).checked;
    if (emailTitle.length != "" && emailTitle.length < 2   && chkCustomEmail)
    {
        args.IsValid = false;
    }
}
function ValidateEmailTypeRequired(source, args) {
    var chkEBulletin = document.getElementById(GetClientId("chkeBulletin")).checked;
    var chkCustomEmail = document.getElementById(GetClientId("chkCustomEmail")).checked;
    if (!chkCustomEmail && !chkEBulletin)
    {
        args.IsValid = false;
    }
    
}
function ValidateEmailContentRequired(source, args) {
var emailContent = document.getElementById(GetClientId("emailcontent")).value;
    
    if (emailContent=="")
    {
        args.IsValid = false;
    }
}
function ValidateEmailContentMax(source, args) {
    var emailContent = document.getElementById(GetClientId("emailcontent")).value;
    if (emailContent.length > 15000)
    {
        args.IsValid = false;
    }
}
function ValidateSendingDateSyntax(source, args) {
var date_now = new Date();
    var date_sending ;
    var send_year = document.getElementById(GetClientId("startyear")).value;
    var send_month = document.getElementById(GetClientId("startmonth")).value;
    var send_day = document.getElementById(GetClientId("startday")).value;
    //alert(send_year+'/'+send_month+'/'+send_day);
//    if (document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_startyear").selectedIndex > 0 && document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_startmonth").selectedIndex > 0 && document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_startday").selectedIndex > 0)
//    {
//        args.IsValid = false;
//        return;
//    }
    if (!isDate(send_day+'/'+send_month+'/'+send_year) && !isNaN(send_year) && !isNaN(send_day) && !isNaN(send_month))
    {
        args.IsValid = false;
    }
}
/* ----------------- */
/**
 * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}


function validateInteger( strValue ) {
 var objRegExp  = /(^-?\d\d*$)/;

  //check for integer characters
  return objRegExp.test(strValue);
}


function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
//		alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
//		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
//		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
//		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
//		alert("Please enter a valid date")
		return false
	}
return true
}

function ValidateForm(){
	var dt=document.frmSample.txtDate
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }


/*  -----------------*/

function cvValidateRequiredTitle(source, args) {
    //var txttitle = document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_txtTitle").value;
    var txttitle = document.getElementById(GetClientId("txtTitle")).value;
    //alert('client side validation');
    if (txttitle == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredFirstname(source, args) {
    //var txtfirstname = document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_txtFirstname").value;
    var txtfirstname = document.getElementById(GetClientId("txtFirstname")).value;
    if (txtfirstname == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredSurname(source, args) {
    //var txtsurname = document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_txtSurname").value;
    var txtsurname = document.getElementById(GetClientId("txtSurname")).value;
    if (txtsurname == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredOrganisation(source, args) {
    var txtorganisation = document.getElementById(GetClientId("txtOrganisation")).value;//document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_txtOrganisation").value;
    if (txtorganisation == "")
    {
        args.IsValid = false;
    }
//    else if (!isAlphaNumeric(txtorganisation))
//    {
//        args.IsValid = false;
//    }
}
function cvValidateRequiredAddress1(source, args) {
    var txtaddress1 = document.getElementById(GetClientId("txtAddress1")).value;
    if (txtaddress1 == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredAddress2(source, args) {
    var txtaddress2 = document.getElementById(GetClientId("txtAddress2")).value;
    if (txtaddress2 == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredPostCode(source, args) {
    var txtpostcode = document.getElementById(GetClientId("txtPostcode")).value;
    if (txtpostcode == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredCountry(source, args) {
    var ddlcountry = document.getElementById(GetClientId("ddlCountry")).selectedIndex;
    if (ddlcountry == 0)
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredEmail(source, args) {
    var txtemail = document.getElementById(GetClientId("txtEmailAddress")).value;
    args.IsValid = true;
    if (txtemail == "")
    {
        args.IsValid = false;
    }
    if (!isValidEmail(txtemail))
    {
        args.IsValid = false;
    }
}
function cvValidateSameEmail(source, args) {
    var txtemail = document.getElementById(GetClientId("txtEmailAddress")).value;
    var txtemailconfirm = document.getElementById(GetClientId("txtEmailAddressConfirm")).value;
    
    if (txtemail != "" && txtemailconfirm != txtemail)
    {
        args.IsValid = false;
    }
}
function cvValidateMembership(source, args) {
    var chkbsecsmember = document.getElementById(GetClientId("rdoBSECSMember")).checked;
    var chkc18member = document.getElementById(GetClientId("rdoC18Member")).checked;
    var chknonmember = document.getElementById(GetClientId("rdoNonMember")).checked;
    if (!chkbsecsmember && !chkc18member && !chknonmember)
    {
        args.IsValid = false;
    }
}
function cvValidateAssociation(source, args) {
    var chkc18member = document.getElementById(GetClientId("rdoC18Member")).checked;
    var txtassociation = document.getElementById(GetClientId("txtSocietyAssociation")).value;
    if (chkc18member && txtassociation == "")
    {
        args.IsValid = false;
    }
//    else if (chkc18member && !isAlphaNumeric(txtassociation))
//    {
//        args.IsValid = false;
//    }
}
function cvValidateConferenceFee(source, args) {
    var chkdiscountedconffee = document.getElementById(GetClientId("rdoDiscountedConfFee")).checked;
    var chkregularconffee = document.getElementById(GetClientId("rdoRegularConfFee")).checked;
    if (!chkdiscountedconffee && !chkregularconffee)
    {
        args.IsValid = false;
    }
}
function cvValidateCompanion(source, args) {
    var chktwinnonpaying = document.getElementById(GetClientId("rdoTwinNotPaying")).checked;
    var chktwinpaying = document.getElementById(GetClientId("rdoTwinPaying")).checked;
    var txtcompanion = document.getElementById(GetClientId("txtCompanionName")).value;
    if ((chktwinnonpaying || chktwinpaying) && txtcompanion == "")
    {
        args.IsValid = false;
    }  
    else if ((chktwinnonpaying || chktwinpaying) && !isAlphaNumeric(txtcompanion))
    {
        args.IsValid = false;
    }
    else if (txtcompanion != "" && !isAlphaNumeric(txtcompanion))
    {
        args.IsValid = false;
    }
}
function cvValidateCompanionEmail(source, args) {
    var chktwinnonpaying = document.getElementById(GetClientId("rdoTwinNotPaying")).checked;
    var chktwinpaying = document.getElementById(GetClientId("rdoTwinPaying")).checked;
    var txtcompanionemail = document.getElementById(GetClientId("txtCompanionEmail")).value;
    if ((chktwinnonpaying || chktwinpaying) && (txtcompanionemail == "" || !isValidEmail(txtcompanionemail)))
    {
        args.IsValid = false;
    } 
}
function cvValidateIndividualMeals(source, args) {
    var chktwinnonpaying = document.getElementById(GetClientId("rdoSelectMeals")).checked;
    var chkmeal1 = document.getElementById(GetClientId("chkDinner5Jan")).checked;
    var chkmeal2 = document.getElementById(GetClientId("chkBreakfast6Jan")).checked;
    var chkmeal3 = document.getElementById(GetClientId("chkLunch6Jan")).checked;
    var chkmeal4 = document.getElementById(GetClientId("chkBreakfast7Jan")).checked;
    var chkmeal5 = document.getElementById(GetClientId("chkLunch7Jan")).checked;
    var chkmeal6 = document.getElementById(GetClientId("chkAnnualDinner")).checked;
    if (chktwinnonpaying && !chkmeal1 && !chkmeal2 && !chkmeal3 && !chkmeal4 && !chkmeal5 && !chkmeal6)
    {
        args.IsValid = false;    
    }    
}
function cvValidateSpecialRequirementsMax(source, args) {
    var txtspecialrequirements = document.getElementById(GetClientId("txtSpecialRequirements")).value;
    if (txtspecialrequirements.length > 1000)
    {
        args.IsValid = false;    
    }    
}
function cvValidateSpecialDietMax(source, args) {
    var txtspecialdiet = document.getElementById(GetClientId("txtSpecialDiet")).value;
    if (txtspecialdiet.length > 1000)
    {
        args.IsValid = false;    
    }    
}
function cvValidateSpecialDietCharacters(source, args) {
    var txtspecialdiet = document.getElementById(GetClientId("txtSpecialDiet")).value;
    if (!isAlphaNumericWithPunctuations(txtspecialdiet))
    {
        args.IsValid = false;    
    }  
}
function cvValidateSpecialRequirementsCharacters(source, args) {
    var txtspecialrequirements = document.getElementById(GetClientId("txtSpecialRequirements")).value;
    if (!isAlphaNumericWithPunctuations(txtspecialrequirements))
    {
        args.IsValid = false;    
    } 
}
function ValidateEmailTitleCharacters(source, args) {
    var txtemailtitle = document.getElementById(GetClientId("emailtitle")).value;
    if (txtemailtitle !="" && !isAlphaNumeric(txtemailtitle))
    {
        args.IsValid = false;    
    } 
}
