﻿// JScript File

             function fillCountryCode(obj)
             {
                if(obj.options[obj.options.selectedIndex].value != "-1")
                {
                  var Code = obj.options[obj.options.selectedIndex].value.split('-') ;
                  var txtCountryCode = document.getElementById('txtContactCountryCode');
                  txtCountryCode.value = Code[2];
                }
                else
                {
                    document.getElementById('txtContactCountryCode').value = "";
                }
             }
             function validate()
             {
               var obj = document.getElementById('ddltitle');
               if(obj.options[obj.options.selectedIndex].value == "-1")
               {
                         alert("Please Select Title");
                         obj.focus();
                         return false;
               }
               obj = document.getElementById('txtName');
               if(!(chkEmpty(obj,"first name") && chkLength(obj,"First name",3,25) && chkPattern(obj,"First name",/^\s*([A-Z]|[a-z])/)))
               {
                    return false;
               }               
               obj = document.getElementById('txtLastName');
               if(!(chkEmpty(obj,"last name") && chkLength(obj,"Last name",3,25) && chkPattern(obj,"last name",/^\s*([A-Z]|[a-z])/)))
               {
                    return false;
               } 
               
                     
               obj = document.getElementById('ddlCountry');
               if(obj.options[obj.options.selectedIndex].value == "-1")
               {
                         alert("Please Select Country of residence");
                         obj.focus();
                         return false;
               }     
                 obj = document.getElementById('txtContactAreaCode');
                if(!(chkEmpty(obj,"area code") && chkLength(obj,"Area code",1,3) && chkPattern(obj,"area code",/^\d*[0-9]?$/)))
               {
                    return false;
               } 
                     
                obj = document.getElementById('txtContactNo');
               if(!(chkEmpty(obj,"contact number") && chkLength(obj,"Contact number",5,9) && chkPattern(obj,"contact number",/^\d*[0-9]?$/)))
               {
                    return false;
               } 
               obj = document.getElementById('txtEmail');
               if(!(chkEmpty(obj,"email address") && chkPattern(obj,"email address",/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)))
               {
                    return false;
               }       
                 obj = document.getElementById('txtPropertyLocated');
               if(!chkEmpty(obj,"property located"))
               {
                    return false;
               } 
                obj = document.getElementById('ddlPropertyType');
                if(obj.options[obj.options.selectedIndex].value == "Not Specified")
               {
                         alert("Please Select Property Type");
                         obj.focus();
                         return false;
               }
             
             }
             
