﻿// JScript File


    function ltrim (s)
        {
            return s.replace( /^\s*/, "" );
        }
        function validate()
        {
            var name=document.getElementById("TextBox1");
            var mobile=document.getElementById("TextBox2");
            var sub=document.getElementById("txtsub");           
            var email=document.getElementById("txtfrom");
             
             var email1=document.getElementById("txtto");
       var feed=document.getElementById("txtbody");   
 
           
           
            
            if (ltrim(name.value)=="")
            { alert("Please Enter Name"); name.value=""; name.focus(); return false; }
              str2A=name.value;
            var mobExpA = /^[-A-Z a-z]+$/;
	        if(str2A.match(mobExpA)==null)	
	        { alert("Emptyspace is not allowed in name field"); name.focus(); return false; }
	        
	        
                  if (ltrim(mobile.value)=="")
            { alert("Please Enter Mobile No"); mobile.value=""; mobile.focus(); return false; }
              str2=mobile.value;
            var mobExp = /\d{10}/;
	        if(str2.match(mobExp)==null)	
	        { alert("Invalid Mobile No Ex:9790933474"); mobile.focus(); return false; }
	        
	        str2d=mobile.value;
            var mobExpd =/^[0-9]+$/;
	        if(str2d.match(mobExpd)==null)	
	        { alert("Invalid Mobile No Ex:9790933474"); mobile.focus(); return false; }
	        
	           if (mobile.value.length>10)
            { alert("Invalid Mobile No Ex:9790933474"); mobile.focus(); return false; }
            
            
	        
             if (ltrim(email.value)=="")
            { alert("Please Enter From Email Address"); 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 From Email Address"); email.focus(); return false; }
	        
	          if (ltrim(email1.value)=="")
            { alert("Please Enter To Email Address"); email1.value=""; email1.focus(); return false; }
            
             str1=email1.value;
            var emailExp1 = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	        if(str1.match(emailExp1)==null)	
	        { alert("Invalid To Email Address"); email1.focus(); return false; }
	        
	               if (ltrim(sub.value)=="")
            { alert("Please Enter Subject"); sub.value=""; sub.focus(); return false; }
             
             
              if (ltrim(feed.value)=="")
            { alert("Please Enter Message"); feed.value=""; feed.focus(); return false; }
             
	        
         
            
           
            
        
           
        }


