﻿// JScript File

function MaximumWindow()
{
top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
}

function trim(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
    sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
    sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

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 MsgErrNum(tmpVal)
{
    tmpVal = "`" + tmpVal + "` Mesti Dalam Format Nombor";
    return tmpVal;
}

function MsgErrBlank(tmpVal)
{
    tmpVal = "`" + tmpVal + "` Tidak Dibenarkan Kosong";
    return tmpVal;
}

function MsgErrDate(tmpVal)
{
    tmpVal = "`" + tmpVal + "` Mesti Dalam Format Yang Dibenarkan";
    return tmpVal;
}
function MsgErrComboBox(tmpVal)
{
    tmpVal ="Sila Pilih Salah Satu Nilai Daripada" + "`" + tmpVal + "`";
    return tmpVal;
}
function isFloat(s)
{
    var i;
    var dec;
    dec="";
    
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) 
        {
            if (c!=".")
            {
                return false;
            }
            if (c=="." && dec=="1")
            {
                return false;
            }
            
            //Only Allow 1 dot
            if (c=="." && dec=="")
            {
                dec="1";
            }
        }
    }
    // All characters are numbers.
    return true;
}


function emailCheck (emailStr) 
        {
                /* The following variable tells the rest of the function whether or not
                to verify that the address ends in a two-letter country or well-known
                TLD.  1 means check it, 0 means don't. */

                var checkTLD=1;

                /* The following is the list of known TLDs that an e-mail address must end with. */

                var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

                /* The following pattern is used to check if the entered e-mail address
                fits the user@domain format.  It also is used to separate the username
                from the domain. */

                var emailPat=/^(.+)@(.+)$/;

                /* The following string represents the pattern for matching all special
                characters.  We don't want to allow special characters in the address. 
                These characters include ( ) < > @ , ; : \ " . [ ] */

                var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

                /* The following string represents the range of characters allowed in a 
                username or domainname.  It really states which chars aren't allowed.*/

                var validChars="\[^\\s" + specialChars + "\]";

                /* The following pattern applies if the "user" is a quoted string (in
                which case, there are no rules about which characters are allowed
                and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
                is a legal e-mail address. */

                var quotedUser="(\"[^\"]*\")";

                /* The following pattern applies for domains that are IP addresses,
                rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
                e-mail address. NOTE: The square brackets are required. */

                var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

                /* The following string represents an atom (basically a series of non-special characters.) */

                var atom=validChars + '+';

                /* The following string represents one word in the typical username.
                For example, in john.doe@somewhere.com, john and doe are words.
                Basically, a word is either an atom or quoted string. */

                var word="(" + atom + "|" + quotedUser + ")";

                // The following pattern describes the structure of the user

                var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

                /* The following pattern describes the structure of a normal symbolic
                domain, as opposed to ipDomainPat, shown above. */

                var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

                /* Finally, let's start trying to figure out if the supplied address is valid. */

                /* Begin with the coarse pattern to simply break up user@domain into
                different pieces that are easy to analyze. */

                var matchArray=emailStr.match(emailPat);

                if (matchArray==null)
                {
                    /* Too many/few @'s or something; basically, this address doesn't
                    even fit the general mould of a valid e-mail address. */
                
                    //alert("Alamat Email Mesti Dalam Format Yang Betul");
                    //alert("Email address seems incorrect (check @ and .'s)");
                    return false;
                }
                var user=matchArray[1];
                var domain=matchArray[2];

                // Start by checking that only basic ASCII characters are in the strings (0-127).

                for (i=0; i<user.length; i++) 
                {
                    if (user.charCodeAt(i)>127) 
                    {
                    //alert("Alamat Email Mesti Dalam Format Yang Betul");
                    //alert("Ths username contains invalid characters.");
                    return false;
                   }
                }
                
                for (i=0; i<domain.length; i++) 
                {
                    if (domain.charCodeAt(i)>127) 
                    {
                        //alert("Alamat Email Mesti Dalam Format Yang Betul");
                        //alert("Ths domain name contains invalid characters.");
                        return false;
                   }
                }

                // See if "user" is valid 

                if (user.match(userPat)==null) 
                {
                    // user is not valid
                    //alert("Alamat Email Mesti Dalam Format Yang Betul");
                    //alert("The username doesn't seem to be valid.");
                    return false;
                }

                /* if the e-mail address is at an IP address (as opposed to a symbolic
                host name) make sure the IP address is valid. */

                var IPArray=domain.match(ipDomainPat);
                if (IPArray!=null) 
                {

                    // this is an IP address

                    for (var i=1;i<=4;i++) 
                    {
                        if (IPArray[i]>255) 
                        {
                            //alert("Alamat Email Mesti Dalam Format Yang Betul");
                            //alert("Destination IP address is invalid!");
                            return false;
                        }
                    }
                    return true;
                }

                // Domain is symbolic name.  Check if it's valid.
                 
                var atomPat=new RegExp("^" + atom + "$");
                var domArr=domain.split(".");
                var len=domArr.length;
                for (i=0;i<len;i++) 
                {
                    if (domArr[i].search(atomPat)==-1) 
                    {
                        //alert("Alamat Email Mesti Dalam Format Yang Betul");
                        //alert("The domain name does not seem to be valid.");
                        return false;
                   }
                }

                /* domain name seems valid, but now make sure that it ends in a
                known top-level domain (like com, edu, gov) or a two-letter word,
                representing country (uk, nl), and that there's a hostname preceding 
                the domain or country. */

                if (checkTLD && domArr[domArr.length-1].length!=2 && 
                domArr[domArr.length-1].search(knownDomsPat)==-1) 
                {
                    //alert("Alamat Email Mesti Dalam Format Yang Betul");
                    //alert("The address must end in a well-known domain or two letter " + "country.");
                    return false;
                }

                // Make sure there's a host name preceding the domain.

                if (len<2)
                {
                    //alert("Alamat Email Mesti Dalam Format Yang Betul");
                    //alert("This address is missing a hostname!");
                    return false;
                }

                // If we've gotten this far, everything's valid!
                     return true;
            }
            
            
function isDate(dateStr, dateName) {
    var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
    var matchArray = dateStr.match(datePat); 
    var myArray = new Array();
    myArray[1] = "January";
    myArray[2] = "February";
    myArray[3] = "March";
    myArray[4] = "April";
    myArray[5] = "May";
    myArray[6] = "June";
    myArray[7] = "July";
    myArray[8] = "August";
    myArray[9] = "September";
    myArray[10] = "October";
    myArray[11] = "November";
    myArray[12] = "December";
 
    if (matchArray == null) {
    alert("" + dateName +  " must be in dd/mm/yyyy format.");
    return false;
    }

    month = matchArray[1]; 
    day = matchArray[3];
    year = matchArray[5];
    
    if (year < 1900 || year > 2079) {
    alert("Year of " + dateName +  " must be between 1900 to 2079.");
    return false;
    }

    if (month < 1 || month > 12) { // check month range
    alert("Month of  " + dateName +  " must be between 1 to 12.");
    return false;
    }

    if (day < 1 || day > 31) {
    alert("Day of " + dateName +  " must be between 1 to 31.");
    return false;
    }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
    alert("No day 31 in " + myArray[month*1] + ".");
    return false;
    }

    if (month == 2) { // check for february 29th
    var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
    if (day > 29 || (day==29 && !isleap)) {
    alert("No day " + day + " in February year " + year + ".");
    return false;
    } 
}
    return true; // date is valid
}

function isDateBM(dateStr, dateName) {
    var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
    var matchArray = dateStr.match(datePat); 
    var myArray = new Array();
    myArray[1] = "Januari";
    myArray[2] = "Februari";
    myArray[3] = "Mac";
    myArray[4] = "April";
    myArray[5] = "Mei";
    myArray[6] = "Jun";
    myArray[7] = "Julai";
    myArray[8] = "Ogos";
    myArray[9] = "September";
    myArray[10] = "Oktober";
    myArray[11] = "November";
    myArray[12] = "Disember";
 
    if (matchArray == null) {
    alert("Tarikh bagi " + dateName +  " mesti dalam format dd/mm/yyyy");
    return false;
    }

    month = matchArray[1]; 
    day = matchArray[3];
    year = matchArray[5];
    
    if (year < 1900 || year > 2079) {
    alert("Tahun tarikh bagi " + dateName +  " mesti di antara 1900 hingga 2079.");
    return false;
    }

    if (month < 1 || month > 12) { // check month range
    alert("Bulan tarikh bagi " + dateName +  " mesti di antara 1 hingga 12.");
    return false;
    }

    if (day < 1 || day > 31) {
    alert("Hari tarikh bagi " + dateName +  " mesti di antara 1 hingga 31.");
    return false;
    }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
    alert("Bulan "+myArray[month*1]+" tidak mempunyai 31 hari.");
    return false;
    }

    if (month == 2) { // check for february 29th
    var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
    if (day > 29 || (day==29 && !isleap)) {
    alert("Bulan Februari tahun " + year + " tidak mempunyai " + day + " hari.");
    return false;
    } 
}
    return true; // date is valid
}


/*==========================================================================# 
# * Function for adding a Filter to an Input Field                          # 
# * @param  : [filterType  ] Type of filter 0=>Alpha, 1=>Num, 2=>AlphaNum   # 
# * @param  : [evt         ] The Event Object                               # 
# * @param  : [allowDecimal] To allow Decimal Point set this to true        # 
# * @param  : [allowCustom ] Custom Characters that are to be allowed       #
'weberdev.com/get_example-4437.html 
#==========================================================================*/ 
function filterInput(filterType, evt, allowDecimal, allowCustom){ 
    var keyCode, Char, inputField, filter = ''; 
    var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; 
    var num   = '0123456789'; 
    // Get the Key Code of the Key pressed if possible else - allow 
    if(window.event){ 
        keyCode = window.event.keyCode; 
        evt = window.event; 
    }else if (evt)keyCode = evt.which; 
    else return true; 
    // Setup the allowed Character Set 
    if(filterType == 0) filter = alpha; 
    else if(filterType == 1) filter = num; 
    else if(filterType == 2) filter = alpha + num; 
    if(allowCustom)filter += allowCustom; 
    if(filter == '')return true; 
    // Get the Element that triggered the Event 
    inputField = evt.srcElement ? evt.srcElement : evt.target || evt.currentTarget; 
    // If the Key Pressed is a CTRL key like Esc, Enter etc - allow 
    if((keyCode==null) || (keyCode==0) || (keyCode==8) || (keyCode==9) || (keyCode==13) || (keyCode==27) )return true; 
    // Get the Pressed Character 
    Char = String.fromCharCode(keyCode); 
    // If the Character is a number - allow 
    if((filter.indexOf(Char) > -1)) return true; 
    // Else if Decimal Point is allowed and the Character is '.' - allow 
    else if(filterType == 1 && allowDecimal && (Char == '.') && inputField.value.indexOf('.') == -1)return true; 
    else return false; 
}



function filterInputDec1(evt){
     var keyCode, Char, inputField,evt, filter = ''; 
     var num   = '0123456789'; 
       if(window.event){ 
            keyCode = window.event.keyCode; 
            evt = window.event; 
        }else if (evt)keyCode = evt.which; 
    else return true; 
   
    filter = num; 
    
    if(filter == '')return true; 
    
    inputField = evt.srcElement ? evt.srcElement : evt.target || evt.currentTarget;
    
    if (document.selection.type == 'Text') { 
            inputField.value='';
    } 
       
    if((keyCode==null) || (keyCode==0) || (keyCode==8) || (keyCode==9) || (keyCode==13) || (keyCode==27) )return true; 
   
     Char = String.fromCharCode(keyCode); 
    
   if((inputField.value.length - inputField.value.indexOf('.') -1)!=0)    
     if (inputField.value !='' && isDecimal1(inputField.value)==false ) return false;
 
   

   if((filter.indexOf(Char) > -1)) return true; 
    else if(Char == '.' && inputField.value.indexOf('.') == -1)return true;
    else return false; 
}

function isDecimal1(str) {
   
   str = str.replace(/^\s+|\s+$/g, '');
   
 return /^[-+]?\d{0,2}(\.\d{0,0})?$/.test(str); // 0,0 allow one decimal when key press

}

function isDecimal2(str) {
   
   str = str.replace(/^\s+|\s+$/g, '');
   
 return /^[-+]?\d{0,4}(\.\d{0,1})?$/.test(str); // 0,1 allow one decimal when lost focus(blur)

}

function MsgCheckDecimal1(bEnglish,cid)
{
if (isDecimal2(document.getElementById(cid).value)==false){
    if(bEnglish == 'True'){
        alert('Please Enter Number/Number with one decimal value.' );
    
    } else
    { 
       alert ('Sila isikan Nombor/Nombor dengan satu tempat perpuluhan sahaja.' );
    }
    document.getElementById(cid).value='';
    document.getElementById(cid).focus()
    }
}


function noSpaceAllowed(event)
{
    if(window.event){ 
        keyCode = window.event.keyCode; 
        evt = window.event; 
       if (keyCode == 32) {return false;}
    }else if (evt)keyCode = evt.which; 
    else return true; 
}


function MsgTextBlank(bEnglish, desc) {
    if(bEnglish == 'True'){
        alert('Please enter ' + desc + '.' );
    
    } else
    { 
       alert ('Sila isikan ' + desc + '.' );
    }
}

function MsgComboBlank(bEnglish, desc) {
    if(bEnglish =='True'){
        alert('Please select ' + desc + '.' );
    
    } else
    { 
       alert ('Sila pilih ' + desc + '.' );
    }
}

function MsgDigit(bEnglish, strvalue, strlength, desc ) {

    if(bEnglish =='True'){
       if (isNaN(strvalue)) {
           alert(desc + ' must be in number format.');
           return false;
       } 
       
       if (strvalue.length != strlength) {
           alert(desc + ' must be in ' + strlength + ' digit(s).');
           return false;
       }
    
    } else
    { 
       if (isNaN(strvalue)) {
           alert(desc + ' mesti dalam format nombor.');
           return false;
       } 
       if (strvalue.length != strlength) {
           alert(desc + ' mesti dalam ' + strlength + ' digit.');
           return false;
       }
    }
    return true;
}

function MsgIsDate(bEnglish, dateStr, dateName) {
    var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
    var matchArray = dateStr.match(datePat); 
    var myArray = new Array();
        
    if (bEnglish == 'True') {
        myArray[1] = "January";
        myArray[2] = "February";
        myArray[3] = "March";
        myArray[4] = "April";
        myArray[5] = "May";
        myArray[6] = "June";
        myArray[7] = "July";
        myArray[8] = "August";
        myArray[9] = "September";
        myArray[10] = "October";
        myArray[11] = "November";
        myArray[12] = "December";
     
        if (matchArray == null) {
        alert("" + dateName +  " must be in dd/mm/yyyy format.");
        return false;
        }

        month = matchArray[1]; 
        day = matchArray[3];
        year = matchArray[5];
        
        if (year < 1900 || year > 2079) {
        alert("Year of " + dateName +  " must be between 1900 to 2079.");
        return false;
        }

        if (month < 1 || month > 12) { // check month range
        alert("Month of  " + dateName +  " must be between 1 to 12.");
        return false;
        }

        if (day < 1 || day > 31) {
        alert("Day of " + dateName +  " must be between 1 to 31.");
        return false;
        }

        if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        alert("No day 31 in " + myArray[month*1] + ".");
        return false;
        }

        if (month == 2) { // check for february 29th
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
        alert("No day " + day + " in February year " + year + ".");
        return false;
        } 
    }
        return true; // date is valid  
    
    }else
    {
        myArray[1] = "Januari";
        myArray[2] = "Februari";
        myArray[3] = "Mac";
        myArray[4] = "April";
        myArray[5] = "Mei";
        myArray[6] = "Jun";
        myArray[7] = "Julai";
        myArray[8] = "Ogos";
        myArray[9] = "September";
        myArray[10] = "Oktober";
        myArray[11] = "November";
        myArray[12] = "Disember";
     
        if (matchArray == null) {
        alert("" + dateName +  " mesti dalam format dd/mm/yyyy");
        return false;
        }

        month = matchArray[1]; 
        day = matchArray[3];
        year = matchArray[5];
        
        if (year < 1900 || year > 2079) {
        alert("Tahun " + dateName +  " mesti di antara 1900 hingga 2079.");
        return false;
        }

        if (month < 1 || month > 12) { // check month range
        alert("Bulan " + dateName +  " mesti di antara 1 hingga 12.");
        return false;
        }

        if (day < 1 || day > 31) {
        alert("Hari " + dateName +  " mesti di antara 1 hingga 31.");
        return false;
        }

        if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        alert("Bulan "+myArray[month*1]+" tidak mempunyai 31 hari.");
        return false;
        }

        if (month == 2) { // check for february 29th
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
        alert("Bulan Februari tahun " + year + " tidak mempunyai " + day + " hari.");
        return false;
        } 
    }
        return true; // date is valid
    
    }


}

function MsgConfirmToSave(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to save?');
    
    } else
    
    {
    
        return confirm('Pasti untuk simpan?');
    
    }


}


function MsgConfirmToDelete(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to delete?');
    
    } else
    
    {
    
        return confirm('Pasti untuk hapus?');
    
    }


}

function MsgConfirmToRestore(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to restore?');
    
    } else
    
    {
    
        return confirm('Pasti untuk pulih?');
    
    }


}



function MsgConfirmToCancel(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to cancel?');
    
    } else
    
    {
    
        return confirm('Pasti untuk batal?');
    
    }


}

function MsgConfirmToSubmit(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to submit?');
    
    } else
    
    {
    
        return confirm('Pasti untuk hantar?');
    
    }


}

function MsgConfirmToRegister(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to register?');
    
    } else
    
    {
    
        return confirm('Pasti untuk daftar?');
    
    }


}


function MsgConfirmToCreateNew(bEnglish,tmptext)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to create new?');
    
    } else
    
    {
    
        return confirm('Pasti untuk tambah permohonan baru?');
    
    }


}

function MsgConfirmToDeselect(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to deselect?');
    
    } else
    
    {
    
        return confirm('Pasti untuk batal?');
    
    }


}


function MsgConfirmToAccept(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to accept?');
    
    } else
    
    {
    
        return confirm('Pasti untuk terima?');
    
    }


}


function MsgConfirmToReject(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to reject?');
    
    } else
    
    {
    
        return confirm('Pasti untuk tolak?');
    
    }


}


function MsgConfirmToAdd(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to add?');
    
    } else
    
    {
    
        return confirm('Pasti untuk tambah?');
    
    }


}

function MsgConfirmToApprove(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to approve?');
    
    } else
    
    {
    
        return confirm('Pasti untuk sah?');
    
    }


}


function MsgConfirmToSave(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to save?');
    
    } else
    
    {
    
        return confirm('Pasti untuk simpan?');
    
    }


}


function MsgConfirmToPrint(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to print?');
    
    } else
    
    {
    
        return confirm('Pasti untuk cetak?');
    
    }


}

function MsgConfirmToSaveAndConfirm(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to save and confirm?');
    
    } else
    
    {
    
        return confirm('Pasti untuk simpan dan sah?');
    
    }


}

function MsgConfirmToSuspend(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to suspend?');
    
    } else
    
    {
    
        return confirm('Pasti untuk gantung?');
    
    }


}

function MsgConfirmToRePrint(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to reprint?');
    
    } else
    
    {
    
        return confirm('Pasti untuk cetak semula?');
    
    }


}

function MsgConfirmToActive(bEnglish)  {
    if(bEnglish == 'True') {
        return confirm('Confirm to activate?');
    
    } else
    
    {
    
        return confirm('Pasti untuk aktifkan?');
    
    }


}




function MsgValid(bEnglish, desc) {
    if(bEnglish == 'True'){
        alert('Please enter valid ' + desc + '.' );
    
    } else
    { 
       alert ( desc + ' mesti dalam format yang betul.' );
    }
}

function MsgCompareFailed(bEnglish, desc1, desc2) {
    if(bEnglish == 'True'){
        alert( desc2 + ' Cannot Less Than '+ desc1 +'.' );
    
    } else
    { 
       alert ( desc2 + ' Tidak Boleh Kurang Daripada '+ desc1 +'.' );
    }
}

function MsgCompareValue(bEnglish, desc1, desc2) {
    if(bEnglish == 'True'){
        alert( desc2 + ' Cannot More Than '+ desc1 +'.' );
    
    } else
    { 
       alert ( desc2 + ' Tidak Boleh Lebih Daripada '+ desc1 +'.' );
    }
}

function roundit(Num, Places)
	    {
	      var str = "" + Math.round ( eval(Num) * Math.pow(10,Places));
	      while (str.length <= Places) 
	      {
	        str = "0" + str;
	      }
	       var decpoint = str.length - Places;
	       return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
        }
 function MsgAlphaNum(bEnglish,upass_string,desc){
        var strlength=0;
        strlength =upass_string.length;
        var alphanum_valid="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        for (var i=0; i<strlength; i++) {
           if (alphanum_valid.indexOf(upass_string.charAt(i)) < 0) {
           
             if(bEnglish == 'True'){
                alert('Please enter valid ' + desc + '.' );
            } else
            { 
               alert ( desc + ' mesti dalam format yang betul.' );
            }
                return false;
            }
        }
   return true;
 }     