﻿// JScript File  -- Desgin by DucNT
jQuery(function($){

      $('#ctl00_ContentPlaceHolder1_frvCharityRegister_BirthdaysTextBox').mask('9999');
     
   });

$(document).ready(function() {
          //alert('The DOM is ready!');
         //Regular expressions
        var regs=new Array();
        regs['num']      =/^[0-9]+$/;
        regs['alpha']   =/^[a-zA-Z]+$/;
        regs['alphanum']=/^[a-zA-Z0-9]+$/;
        regs['required']=/^.+$/;
        regs['tick']   =/^1$/; 
        regs['email'] =/^[-+.\w]{1,64}@[-.\w]{1,64}\.[-.\w]{2,6}$/;
        
        
        $("#ctl00_ContentPlaceHolder1_frvCharityRegister_txtReceiptProvinceID").click(function (e)
        {
            if($("#ctl00_ContentPlaceHolder1_frvCharityRegister_txtReceiptProvince").val() == "")
            {
                $("#ctl00_ContentPlaceHolder1_frvCharityRegister_txtReceiptProvince").focus();
            }
            else
            {
                $("#ctl00_ContentPlaceHolder1_frvCharityRegister_txtReceiptDistrict").focus();
            }
        });
      
        
        $("#ctl00_ContentPlaceHolder1_frvCharityRegister_txtReceiptDistrictID").click(function (e)
        {
            if($("#ctl00_ContentPlaceHolder1_frvCharityRegister_txtReceiptDistrict").val() == "")
            {
                $("#ctl00_ContentPlaceHolder1_frvCharityRegister_txtReceiptDistrict").focus();
            }
            else
            {
                $("#ctl00_ContentPlaceHolder1_frvCharityRegister_FullNameTextBox").focus();
            }
        });

      
        $("#ctl00_ContentPlaceHolder1_frvCharityRegister_mobileTextBox").keypress(function (e)  
        { 
              //if the letter is not digit then display error and don't type anything
              if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
              {
                return false;
              }	
        });
        
        $("#ctl00_ContentPlaceHolder1_frvCharityRegister_cashTextBox").keypress(function (e)  
        { 
              //if the letter is not digit then display error and don't type anything
              if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
              {
                return false;
              }	
        });
        
        $("#ctl00_ContentPlaceHolder1_frvCharityRegister_goodsTextBox").keypress(function (e)  
        { 
              //if the letter is not digit then display error and don't type anything
              if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
              {
                return false;
              }	
        });
        
        $("#ctl00_ContentPlaceHolder1_frvCharityRegister_EmailTextBox").blur(function()
        {
            if ($(this).val() != "")
            {
                if(!$(this).val().match(regs['email']))
                {
                    $("#ctl00_ContentPlaceHolder1_frvCharityRegister_EmailTextBox").focus();
                    $("#ctl00_ContentPlaceHolder1_frvCharityRegister_EmailTextBox").val('');
                    alert("Không đúng định dạng Email!");
                }
            }            
        });
        
        $("#ctl00_ContentPlaceHolder1_frvCharityRegister_emailTextBox").blur(function()
        {
            if ($(this).val() != "")
            {
                if(!$(this).val().match(regs['email']))
                {
                    $("#ctl00_ContentPlaceHolder1_frvCharityRegister_emailTextBox").focus();
                    $("#ctl00_ContentPlaceHolder1_frvCharityRegister_emailTextBox").val('');
                    alert("Không đúng định dạng Email!");
                }
            }            
        });
        
        
        //Hiến máu nhân đạo
        $("#ctl00_ContentPlaceHolder1_frvCharityRegister_PhoneNumberTextBox").keypress(function (e)  
        { 
              //if the letter is not digit then display error and don't type anything
              if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
              {
                return false;
              }	
        });
        
        $("#ctl00_ContentPlaceHolder1_frvCharityRegister_IdentityCardTextBox").keypress(function (e)  
        { 
              //if the letter is not digit then display error and don't type anything
              if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
              {
                return false;
              }	
        });
        
//        $('ctl00_ContentPlaceHolder1_frvCharityRegister_EmailTextBox').each(function(){  
//            this.value = $(this).attr('title');  
//            $(this).addClass('text-label');
//              
//        $(this).focus(function(){  
//            if(this.value == $(this).attr('title')) {  
//                    this.value = '';  
//                    $(this).removeClass('text-label');  
//                }  

//            });  
//            $(this).blur(function(){  
//                if(this.value == '') {  
//                    this.value = $(this).attr('title');  
//                    $(this).addClass('text-label');  
//                }  
//            });  

//        }); 

});

function isNumeric(x,RegExp) {
    if(x.match(RegExp)){
         //dom.css("border","thin solid blue");
         return true;
        }
        else{
         //dom.css("border","thin solid red");
        return false;
        }
    }
 
 
       
 
    