How to use the CompareValidator control?

Posted on 2006-05-31
Last Modified: 2008-03-10
I need to implement a text box control with following validation rules:
(1) It should not be blank
(2) It should NOT equal to the string "Please enter your name here"

For first condition, I use Required field validator, it works fine.
For second condition, I think about using CompareValidator. But I need assistance on
(1) How do you set the property of "control to compare"? It compares to itself, actually. Do we need to set it anyway?
(2) How to set the property "Value to compare"? I set it to be the string above. But how do you set condition evaluation to be TRUE or FALSE?
Question by:chuang4630
    LVL 10

    Accepted Solution

    1. the property "control to compare" here you have to set/select the name of control you want to compare with (in your case you can leave it
    2. the property "Value to compare" = "Please enter your name here"
    3. To set the how to evalute there is operator property what should be
    LVL 11

    Expert Comment

    You can set 'Initial Value' of your "Required validator" control to "Please enter your name here", you don't even need to use Compare Validator.  
    LVL 11

    Assisted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now