Title: validate controls                                 If you need copy same format use firefox or chrome or safari but iexplorer not work


Preview of Code
To validate: controls and settings
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
   
 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowSummary="True" ValidationGroup=" "></asp:ValidationSummary>
 
Required
<asp:RequiredFieldValidator CssClass="req" ID="ClientNameValidator" runat="server"
Display="Dynamic" ControlToValidate="txtClientName" ErrorMessage="<%$ Resources:LocalizedText, InvalidReqGeneric%>"  ValidationGroup="">*</asp:RequiredFieldValidator>
 
<asp:RequiredFieldValidator ID="ddlValidator" runat="server" ControlToValidate="ddlCompany"
Display="Dynamic" SetFocusOnError="True" InitialValue="0" ErrorMessage="<%$ Resources:LocalizedText, InvalidReqGeneric %>"  ValidationGroup="">
*</asp:RequiredFieldValidator>
 
 
Phone
<asp:RegularExpressionValidator ID="Phone1Validator" runat="server" ControlToValidate="txtPhoneNumber1"
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidPhone%>"
ValidationExpression="^\+[0-9]{1,3}\.[0-9]{4,14}(?:x.+)?$" ValidationGroup="">!</asp:RegularExpressionValidator>
<asp:TextBoxWatermarkExtender ID="Phone1Watermark" targetcontrolid="txtPhoneNumber1" WatermarkText="+999.9999999999x9999"
runat="server" WatermarkCssClass="watermarked" />
 
 
Fax
<asp:RegularExpressionValidator ID="FaxValidator" runat="server" ControlToValidate="txtFaxNumber1"
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidFax%>"
ValidationExpression="^\+[0-9]{1,3}\.[0-9]{4,14}(?:x.+)?$" ValidationGroup="">!</asp:RegularExpressionValidator>
<asp:TextBoxWatermarkExtender ID="FaxWatermark"  targetcontrolid="txtFaxNumber1" WatermarkText="+999.9999999999x9999"
runat="server" WatermarkCssClass="watermarked" />
 
 
Email
<asp:RegularExpressionValidator ID="EmailValidator" runat="server" ControlToValidate="txtEmail"
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidEmail%>"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="">!</asp:RegularExpressionValidator>
 
 
Website
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtWebsite"
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidWebsite%>"
ValidationExpression="^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\`\/\\\+&amp;%\$#_]*)?$" ValidationGroup="">!</asp:RegularExpressionValidator>
 
 
Mobile
<asp:RegularExpressionValidator ID="ContactMValidator" runat="server" ControlToValidate="txtContactMobile"  ValidationGroup=""
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidMobile%>"
ValidationExpression="^\+[0-9]{1,3}\.[0-9]{9,9}">!</asp:RegularExpressionValidator>
<asp:TextBoxWatermarkExtender ID="ContactMWatermark"  targetcontrolid="txtContactMobile" WatermarkText="+999.123456789"
runat="server" WatermarkCssClass="watermarked" />
 
 
Postal Code
<asp:RegularExpressionValidator ID="ZIPValidator" runat="server" ControlToValidate="txtPostalCode"
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidZIP%>"
ValidationExpression="^(\d{5}-\d{4}|\d{5}|\d{9})$|^([a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d)$" ValidationGroup="">!</asp:RegularExpressionValidator>
 
 
Decimal or Integer
<asp:RegularExpressionValidator ID="CreditValidator" runat="server" ControlToValidate="txtCreditLimit"
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidDecimal%>"
ValidationExpression="^\d+(\.\d\d)?$" ValidationGroup="">!</asp:RegularExpressionValidator>
 
 
Remarks Length
<asp:RegularExpressionValidator ID="RemarksValidator" runat="server" ControlToValidate="txtRemarks"
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidTooLong200 %>"
ValidationExpression="^[\s\S]{0,200}$"  ValidationGroup="">!</asp:RegularExpressionValidator>
 
<asp:RegularExpressionValidator ID="RemarksValidator" runat="server" ControlToValidate="txtRemarks"
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidTooLong100 %>"
ValidationExpression="^[\s\S]{0,100}$"  ValidationGroup="Item">!</asp:RegularExpressionValidator>
 
 
Decimal greater than zero
<asp:CompareValidator ID="CompareValidator1" Display="Dynamic" ControlToValidate="txtCreditLimit"
Type="Double" Operator="GreaterThan" ErrorMessage="<%$ Resources:LocalizedText, InvalidZero%>" Font-Bold="true" ValueToCompare="0"  ValidationGroup=""
runat="server">!</asp:CompareValidator>
 
Date
<asp:CompareValidator ID="DateValidator" Display="Dynamic" ControlToValidate="txtDealingStartDate"
Type="Date" Operator="DataTypeCheck" ErrorMessage="<%$ Resources:LocalizedText, InvalidDate%>" Font-Bold="true"  ValidationGroup="" runat="server">!</asp:CompareValidator>
 
<asp:RequiredFieldValidator CssClass="req" ID="DateReqValidator" runat="server"
Display="Dynamic" ControlToValidate="txtDate" ErrorMessage="<%$ Resources:LocalizedText, InvalidReqDate%>"
ValidationGroup="">*</asp:RequiredFieldValidator>
 
 
PCT %
<asp:RangeValidator ID="PctValidator" ControlToValidate="txtCommissionPct" Display="Dynamic" runat="server"
ErrorMessage="<%$ Resources:LocalizedText, InvalidPct%>" MaximumValue="100.00" MinimumValue="0.00"
Type="Double" ValidationGroup="" Font-Bold="true" >!</asp:RangeValidator>
 
 
Integer
<asp:RegularExpressionValidator ID="OrderValidator" runat="server" ControlToValidate="txtAlternativeOrder"
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidInteger%>"
ValidationExpression="^\d+$" ValidationGroup="Alternatives">!</asp:RegularExpressionValidator>
 
 
Time
<asp:RegularExpressionValidator ID="TimeValidator" runat="server" ControlToValidate="txtTimeFrom"
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidTime%>"
ValidationExpression="^ *(1[0-2]|[1-9]):[0-5][0-9] *(a|p|A|P)(m|M) *$" ValidationGroup="Main">!</asp:RegularExpressionValidator>
 
 
Custom 2-Dates (The CompareValidator works only with MM/dd/yyyy a CustomValidator is needed)
<asp:CustomValidator ID="DateValidator" Display="Dynamic" ControlToValidate="ProjectEndDate" ErrorMessage="<%$ Resources:strings, InvalidEndDateLessThanStart%>" ClientValidationFunction="ClientDateValidator" runat="server"><asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:strings, InvalidEndDateLessThanStart%>" /></asp:CustomValidator>
 
//My custom date parser
function parseFormattedDate(input, format) {
    format = format || `dd/mm/yyyy`; // some default format
    var parts = input.match(/(\d+)/g),
      i = 0, fmt = {};
    // extract date-part indexes from the format
    format.replace(/(yyyy|dd|mm)/g, function (part) { fmt[part] = i++; });
    return new Date(parts[fmt[`yyyy`]], parts[fmt[`mm`]] - 1, parts[fmt[`dd`]]);
}
//This function works with the custom validator to ensure that the end date is greater thsn the start date.
//The CompareValidator in useless here because it handles MM/dd/yyyy only (we`re using dd/MM/yyyy)
function ClientDateValidator(source, arguments) {
    var endDate = parseFormattedDate(arguments.Value, `dd/mm/yyyy`);
    var startDate = parseFormattedDate(document.getElementById(`ProjectStartDate`).value, `dd/mm/yyyy`);
    //start by setting false
    arguments.IsValid = false;
    //end date should be greater than start date
    if (endDate > startDate)
    {
        arguments.IsValid = true;
    }
    else
    return;
    
}
 
 
 
 
 
 
 
 
 
<asp:ValidationSummary ID="ValidationSummary2" runat="server" ShowSummary="True" ValidationGroup="Item"></asp:ValidationSummary>
 
Item
<asp:RequiredFieldValidator CssClass="req" ID="ItemValidator" runat="server"
Display="Dynamic" ControlToValidate="txtItem" ErrorMessage="<%$ Resources:LocalizedText, InvalidReqItem %>" ValidationGroup="Item">*</asp:RequiredFieldValidator>
 
--------------------------------------------------------------------------------------------------------
Quantity
<asp:RequiredFieldValidator CssClass="req" ID="QuantityValidator" runat="server"
Display="Dynamic" ControlToValidate="txtQuantity" ErrorMessage="<%$ Resources:LocalizedText, InvalidReqQuantity %>"
ValidationGroup="Item">*</asp:RequiredFieldValidator>
 
<asp:CompareValidator ID="QuanitityCValidator" Display="Dynamic" ControlToValidate="txtQuantity"
Type="Double" Operator="GreaterThan" ErrorMessage="<%$ Resources:LocalizedText, InvalidZero%>"
Font-Bold="true" ValueToCompare="0" ValidationGroup="Item" runat="server">!</asp:CompareValidator>
 
--------------------------------------------------------------------------------------------------------
Unit
<asp:RequiredFieldValidator ID="ddlUnitValidator" runat="server" ControlToValidate="ddlUnit" Display="Dynamic" InitialValue="0" CssClass="req" ErrorMessage="<%$ Resources:LocalizedText, InvalidReqUnit %>" ValidationGroup="Item">*</asp:RequiredFieldValidator>
 
-------------------------------------------------------------------------------------------------------
Price
<asp:RequiredFieldValidator ID="ddlPriceValidator" runat="server" ControlToValidate="ddlPrice"
Display="Dynamic" InitialValue="0" CssClass="req" ErrorMessage="<%$ Resources:LocalizedText, InvalidReqPrice %>"
ValidationGroup="Item">*</asp:RequiredFieldValidator>
 
------------------------------------------------------------------------------------------------------
Remarks
<asp:RegularExpressionValidator ID="RemarksValidator" runat="server" ControlToValidate="txtRemarks"
Display="Dynamic" Font-Bold="true" ErrorMessage="<%$ Resources:LocalizedText, InvalidTooLong100 %>"
ValidationExpression="^[\s\S]{0,100}$" ValidationGroup="Item">!</asp:RegularExpressionValidator>
 
-----------------------------------------------------------------------------------------------------
Warehouse
<asp:RequiredFieldValidator ID="ddlValidator" runat="server" ControlToValidate="ddlWarehouse"
Display="Dynamic" SetFocusOnError="True" InitialValue="0" ErrorMessage="<%$ Resources:LocalizedText, InvalidReqWH %>"
ValidationGroup="Item">*</asp:RequiredFieldValidator>
 
------------------------------------------------------------------------------------------------------ 
 
function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
          {
             alert("يرجى إدخال أرقام فقط !");
             return false;
         }
         return true;
     }
     function isFloatKey(evt) {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46) {
             alert("يرجى إدخال أرقام فقط !");
             return false;
         }
 
         return true;
     }