﻿// JScript File

//This Function used to Validate Email-ID
function EmailVali()
{
     var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
    var emailid=document.getElementById("<%=BillEmail.ClientID %>").value;
    var matchArray = emailid.match(emailPat);
    if (matchArray == null && emailid!='')
        {
               alert("Your email address seems incorrect. Please try again.");
               document.getElementById("<%=BillEmail.ClientID %>").focus();
               return false;
        }
 }

//To allow only numerics in textbox
//Add Following Code in Page Load
//   TextBoxID1.Attributes.Add("onkeypress","return isNumberKey(event)");
      function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
//To allow "numerics" "+" "-" "," in textbox
//Add Following Code in Page Load
//   TextBoxID1.Attributes.Add("onkeypress","return isPhoneNumber(event)");
      function isPhoneNumber(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57)&& (charCode!=43 && charCode!=44 && charCode!=45))
            return false;

         return true;
      }
//To allow "Alphabetic" "Space" "." "," in textbox
//Add Following Code in Page Load
//   TextBoxID1.Attributes.Add("onkeypress","return isAlphabetic(event)");     
      function isAlphabetic(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 122)&& (charCode !=32 && charCode !=44 && charCode !=46))
         return false;

         return true;
      }


        // Removes leading whitespaces
            function LTrim( value ) {
	            var re = /\s*((\S+\s*)*)/;
	            return value.replace(re, "$1");
            }

         // Removes ending whitespaces
            function RTrim( value ) {
                var re = /((\s*\S+)*)\s*/;
	            return value.replace(re, "$1");
             }

         // Removes leading and ending whitespaces
            function trim( value ) {
                return LTrim(RTrim(value));
             }
 
            function mouseovers(button)
            {
                var but=document.getElementById(button).style.color="Black";
            }
            function mouseouts(button)
            {
                var but=document.getElementById(button).style.color="white";
            }
 
 // Arguments: number to round, number of decimal places
 function roundNumber(rnum, rlength) 
   { 
    var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
        return newnumber; // Output the result to the form field (change for your purposes)
    }