.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Compare validator /Range validator does not work while using localization

Posted By:      Posted Date: October 27, 2010    Points: 0   Category :ASP.Net


I have a requirement of converting existing english form to multi lingual form.I am currently converting english form to spanish form.

Everything works except the date formats.

The range validator is not working in a spanish form but works in a english form.

I have set the maximum and minimum value in page load as below in the english form

Heres how i have set the values

rndateval.MinimumValue = DateTime.Now.AddYears(-50).ToShortDateString();

rndateval.MaximumValue = DateTime.Now.AddDays(20).ToShortDateString();

But the range validator does not work

Please help me in resolving the issue .

View Complete Post

More Related Resource Links

Set up a validator that compare the value of the current field with an other (using Dynamic Data)

Hi! Most of it is in the title : I'd like have a validator on the DateTime_Edit template for example that allows to compare this field with an other DateTime field. My problem is when I am in the DateTime_Edit template of my "master field" (the one I want to check), how can I access to the other field given the architecture of Dynamic Data FieldTemplates? But perhaps I'm not thinking in a good way on this control. Any advice will be welcome. Thanks Raphaelp

How to use compare validator with dd/MM/yyyy format of date

Hi all,  I have a form of leave application that has 2 dates, start date and end date. now i'm using the dd/MM/yyyy format for the date entry and i need to Validate end date like end date must me greater than or equal to start date. i want to do that with compare validator but its not working properly because of the Date  formats controls are using.    Currently i'm using textbox with Calendar extender ajax toolkit control.    So please help me if anybody have some hints.    Thanks in advance.

Can't get MaskedEditExtender/Validator to work

After about two hours of fiddling with it myself and searching the 'Net for anything that would help, I haven't run across anything that seems to help. Here's my code:<ajaxToolkit:MaskedEditExtender ID="editExtSSN" runat="server" TargetControlID="txtInsSSN" Mask="999-99-9999" MaskType="Number" MessageValidatorTip="True" ErrorTooltipEnabled="True" CultureName="en-US" /> <ajaxToolkit:MaskedEditValidator ID="editValidatorSSN" runat="server" ControlExtender="editExtSSN" ControlToValidate="txtInsSSN" ValidationExpression="\d{3}-\d{2}-\d{4}" InvalidValueMessage="Entry is invalid" IsValidEmpty="True" InvalidValueBlurredMessage="*" ValidationGroup="valSSN" Display="Dynamic" /> <asp:TextBox ID="txtInsSSN" runat="server" Width="160px" Font-Size="10px" ValidationGroup="SSN" />  As you can see, I'm simply trying to allow only numbers to be entered in the textbos and validate for an SSN in the format ###-##-####. I've tried everything I can think of and my own social security number won't even validate! I'd really appreciate it if someone can tell me what I'm doing wrong/missing!

Compare Validator not displaying message after postback


Hi all,

I have compare validators that I build on the fly in code behind that validate textboxes that are also built up in the code behind:

CompareValidator CV = new CompareValidator();
CV.ID = "CV" + parameter.Name;
CV.Type = ValidationDataType.Date;
CV.Operator = ValidationCompareOperator.DataTypeCheck;
CV.ErrorMessage = "* Invalid date";
CV.Display = ValidatorDisplay.Static;
CV.ControlToValidate = parameter.Name;
CV.ValidationGroup = "valGroup1";
CV.Style["font"] = "Arial";
CV.Style["color"] = "Red";
CV.Style["font-size"] = "10px";
CV.EnableClientScript = true;


These work fine until a postback occurs. After a postback they still validate the form (i.e. they don't let you postback) but the error message won't display. Can anybody please help?


Range validator broken in MVC 3 Beta 1?


This was all working in MVC3 RC1 (I think MVC2). With the upgrade these are broken.

 I've switched ClientValidationEnabled and Unobtrusive = false, as I couldn't get these to work.



Range(0, 999, ErrorMessage = "Numbers only")


[Range(typeof(decimal), "0.0", "100.00", ErrorMessage="Not a margin number 0.0 - 100.00!")]






Compare validator type nvarchar


Hello  i am using sql datasource to fill my 2 dropdownlist 


first dropdownlist1                                  Second Dropdownlist2

       week1                                                    week1

       week2                                                    week2


Compare validator in a Gridview EditItemTemplate


I am trying to use a compare validator in the EditItemTemplate for the Gridview.

I would like to set the Maximum value for the validator at runtime e.g. Page_Load


Is there a way to set the Maximum value for a "Template field" dynamically at load time


Snippet of code:

 <asp:TemplateField HeaderText="Birth Year" SortExpression="MemberBirthYear">
                           <asp:TextBox ID="eitMemberBirthYear" runat="server" CssClass="eitField"
                              Text='<%# Bind("MemberBirthYear") %>' Width="60px"></asp:TextBox>
                           <asp:RequiredFieldValidator ID="Re

Compare Validator Problem?



I would like to compare a textbox against a value. I want to show validatorcalloutextender if value in Textbox lessthan specific value in validator.Here is the code:

<asp:CompareValidator ID="CompareValidator3" runat="server" ControlToValidate="TextBox2"
            Type="Double" ValueToCompare="1" Text='<img src="Images/validation_error.png">'

Compare Validator

I am using Compare Validator for Comparing Dates. But it doesn't work for MM/dd/yyyy format. It works for dd/MM/yyyy. Why so, as the US format for date is "MM/dd/yyyy" ? Also SQL Server saves dates in MM/dd/yyyy format by default. And why compare validator is working for dd/MM/yyyy? It should not work in both cases or it should work in both cases. Don't you think it should be fixed? Why to waste time for making Custom Validator?

Validator code keeling over


I'm posting in this forum, as it seems the best place for looking at some horrible Javascript!  In essence, I'm trying to hook into a RangeValidator on the client side - nothing special, just asking it to revalidate.  So, I have this in my VB:

 objDescriptor.AddProperty("DateRangeValidator", rvDateInput.ClientID)

and this in my JS: 

// First the constructor
this._DateRangeValidator = null; 

// Then the prototype
get_DateRangeValidator: function () {
        return this._DateRangeValidator;

    set_DateRangeValidator: function (value) {
        this._DateRangeValidator = value;


That's no different from many of the other references I am passing around, and which all work.  So, I'd expect this:


to "just work" and re-evaluate the validity - I think!  What I am actually seeing is:

function ValidatorUpdateDisplay(val) {
    if (typeof(v

Outline doesn't appear around the Validator Callout Extender's callout


For some reaon the black outline isn't appearing around my Validator Callout Extender's callout box.  I don't have a css class set.  It should display a yellow callout with a black outline.  Like on the sample page: http://www.asp.net/ajax/ajaxcontroltoolkit/samples/ValidatorCallout/ValidatorCallout.aspx .

 It shows the yellow call out with the black outline around the pointed part but not the main box.  Any idea's on why this is happening?

Custom Validator


I need to validate a field that depends from a selection of a dropdownlist.

Like, if on dropdown the selected value is 'N' then validate. But it it's 'S', ignores validation;

Is there a way to do this with custom validator ??

I tried but, it's not working.

function chkEndereco(source, args){
   var cmbOnde = $('select[id$=comboOnde]');
   if(cmbOnde.val() == 'N')
      args.IsValid = (args.Value == '')
   if(cmbOnde.val() == 'S')
     args.IsValid = true

<asp:TextBox ID="Endereco" name="endereco" runat="server" AutoCompleteType="none" autocomplete="off" />
                                    <ajaxToolKit:TextBoxWatermarkExtender ID="wmEndereco" runat="server" TargetControlID="Endereco" WatermarkText="Endereço (rua, avenida, etc)" />
                                    <asp:RequiredFieldValidator ID="rqEndereco" runat="server" ErrorMessage="Ops! Faltou o endereço." EnableClientScript="true" ControlToValidate="Endereco" Display="None"/>
                                    <asp:CustomValidator ID="crqEndereco" runat="server" ErrorMe

Localization .RESX files - How to work with translators


I understand I need to place all the translated strings in .RESX files. How do I work with translators??? I do not think they will be able to open RESX files? Please advise your existing method of working with them. They mostly know Word... :)


Creating a Validator class for a custom activity

I created a new Workflow Activity Library and then added a new Activity called BindForm2Activity. After that I added a new class called BindForm2Validator and then placed an attribute to the BindForm2Activity to link it to the validator class.   Here is the code for each of the classes:   BindForm2Activity.xoml.cs: Code Snippet   using System;using System.ComponentModel;using System.ComponentModel.Design;using System.Collections;using System.Drawing;using System.Linq;using System.Workflow.ComponentModel.Compiler;using System.Workflow.ComponentModel.Serialization;using System.Workflow.ComponentModel;using System.Workflow.ComponentModel.Design;using System.Workflow.Runtime;using System.Workflow.Activities;using System.Workflow.Activities.Rules; using FormsCollection;using Utils; namespace ActivityLibrary{    [ActivityValidator(typeof(BindForm2Validator))] public partial class BindForm2Activity : SequenceActivity {        public static DependencyProperty FormToBindProperty = System.Workflow.ComponentModel.DependencyProperty.Register("FormToBind", typeof(FormsCollection.Form2), typeof(BindForm2Activity));         [Description("Form to bind a datasource to it ")]        [Category("BindForm2ToDataSource")]        [Browsable(true)]        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]        public FormsCollection.Form2 Form

custom validator

Is it possible to pass the maximum character length to validateCharacter, rather than just have it set in stone.<asp:CustomValidator ID="ValCharacter" ControlToValidate="txtCharacter"  OnServerValidate="validateCharacter"  Text="Too many characters" runat="server" Display="Dynamic" />        Protected Sub validateCharacter(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)        Dim iChars As Integer = 500        If args.Value.Length > iChars Then            args.IsValid = False        End If    End Subthanks.

Custom Validator on DDL&Textbox values

I need to write a 2 custom validators that works as follows: I have a formview (Formview1) with an EditItemTemplate. The validators need to validate values in "DropDownList1" and a textbox called "EndUserGUIDTextBox" If the value in DDL1 is ("Assigned" or "Assigned to End User") and the value of EndUserGUIDTextBox is ("unassigned" or "pending" or NULL) then I need a validator to fire and return {"GUID must be assigned when status is" & DLL1 value}. If the value in DDL1 is ("In Stock" or "In Repair") and EndUserGUIDTextBox is NOT ("unassigned" or "pending" or NULL), then I need a validator to fire and return {"GUID must not be assigned when status is" & DLL1 Value}. The validators needs to run and show in the formview when the UpdateButton in my Formview is clicked. I'm doing this in VB. Real noobie here! All help appreciated. Thanks,

Negate predefined words using Regular Expression Validator

Hi Any one please tell a regular expression which allow all, except some predefined words. For example user should add their imaginary planet names to text field. So if he typed the existing planet names regular field validation don't allow further. i tried [^({Mercury})|({Venus})|({Earth})|({Mars})|({Jupiter})|({Saturn})|({Uranus})|({Neptune})|({Ceres})|({Ploto})|({Haumea})|({Makemake})|({Eris})] but not working. Its not working for any strings. Please tell me the correct way to do this One more thing i want to know is how lengthy expression can be given to the Regular Expression Validator. Thanks Akeeq
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend