﻿function VC_Require(id,msg)
    {
	    var ctr  = document.getElementById(id);
	    var Prefix_Msg = 'Vui lòng nhập ';
	    if (ctr == null) return true;
	    switch(ctr.tagName.toLowerCase())
	    {
	        case "select":
	            if (ctr.selectedIndex <= 0)
	            { 
		            alert(Prefix_Msg + msg);
		            ctr.focus();
		            return false;			
	            }
	        break;
	        case "input":
	            if (ctr.value.length == 0)
	            { 
		            alert(Prefix_Msg + msg);
		            ctr.focus();
		            return false;			
	            }
	        break;
	        default :
	            if (ctr.value.length == 0)
	            { 
		            alert(Prefix_Msg + msg);
		            ctr.focus();
		            return false;			
	            }
	        break;
	    }
    	
	    return true;
    }

    function VC_IsNumber(ctr,msg)
    {
        var w = document.getElementById(id);
        alert(w);
        alert(w.value);
	    var result = isNaN(w.value);
	    if (result)
	    {
	        alert(msg);
		    w.focus();
		    return false;	
	    }
	    return true;
    }
    
    function checkMail(id, msg)
    {
        var ctr = document.getElementById(id);
        var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (filter.test(ctr.value)) {return true;}
        else {alert(msg); ctr.focus(); return false;}
    }
    
    

