﻿// JScript File
 function ltrim (s)
        {
            return s.replace( /^\s*/, "" );
        }
             function trim(s)
{
    //s=s.replace(/^\s*/,"");
    return s.replace(/^\s+|\s+$/g,"");
}
        function validate()
        {
            var fname=document.getElementById("txtUsername");
            var mobile=document.getElementById("txtphone");
            var email=document.getElementById("txtemail");
           
           var naExp=/^([a-zA-Z\s])+$/;
            
             if (ltrim(fname.value)=="")
            { alert("Please enter Name"); fname.value=""; fname.focus(); return false; }
                else if((trim(fname.value).length!=fname.value.length)||(fname.value.match(naExp)==null))
    {  alert("Name contain illegal characters!"); fname.focus(); return false; }
	        
            
             if (ltrim(mobile.value)=="")
            { alert("Please enter  mobile number"); mobile.value=""; mobile.focus(); return false; }
             var str=mobile.value;
            var mobileExp = /^\d{10}$/;
	        if(str.match(mobileExp)==null)	
	        { alert("Mobile should be numeric & 10 digits"); mobile.focus(); return false; }
	        
	        
	        
            
             if (ltrim(email.value)=="")
            { alert("Please enter Email"); email.value=""; email.focus(); return false; }
            
            str=email.value;
            var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	        if(str.match(emailExp)==null)	
	        { alert("Invalid Email, Please re-enter"); email.focus(); return false; }
	        
	        
	        }
	        
	        function changepassword()
        {
            var password=document.getElementById("TextBox1");
            var newpwd=document.getElementById("TextBox2");
            var confirmpwd=document.getElementById("TextBox3");
            var c=/\W/;
            var d=/[\W_]/;
            
            
            if (ltrim(password.value)=="")
            { alert("Please enter Password"); password.value=""; password.focus(); return false; }
             else if(d.test(password.value))
    { alert("The Password contains illegal characters!"); password.focus(); return false; }
            
            
                      
            
            if (ltrim(newpwd.value)=="")
            { alert("Please enter New Password"); newpwd.value=""; newpwd.focus(); return false; }
            if (newpwd.value.length<5)
            { alert("Password should minimum 5 characters"); newpwd.focus(); return false; }
              if (newpwd.value.length>12)
            { alert("Password should Maximum 12 characters"); newpwd.focus(); return false; }
            
            else if(d.test(newpwd.value))
    { alert("The Password contains illegal characters!"); newpwd.focus(); return false; }
            
            if (ltrim(confirmpwd.value)=="")
            { alert("Please enter confirm Password"); confirmpwd.value=""; confirmpwd.focus(); return false; }
            
            if (newpwd.value!=confirmpwd.value)
            { alert("Password entries didn't match."); newpwd.focus(); return false; }
            
            

	        
           }
            
            
            
            
            
            
            


