Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6171203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:10:23+00:00 2026-05-23T23:10:23+00:00

I need to write simple page with 3 textBox 1. textBox1 ==> contain number

  • 0

I need to write simple page with 3 textBox
1. textBox1 ==> contain number only
2. textBox2 ==> contain Email address
3. textBox3 ==> contain user name only

I want to make some validation check on each textBox – and in case there is some problem with the user input – to make the textBox border to be in red color and show right message about the error.

How can i do it ?

Thanks for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:10:24+00:00Added an answer on May 23, 2026 at 11:10 pm

    Here is a sample: SimpleValidation

    enter image description here

    It makes use of DataAnnotations so you can set your validation in the attribute.

    Here is the code:

    MainPage.cs

    public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
                DataContext = new DataModel();
            }
        }
    

    MainPage.xaml

    <UserControl x:Class="Org.Vanderbiest.SimpleValidation.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
    
        <Grid x:Name="LayoutRoot" Background="White">
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
            </Grid.ColumnDefinitions>
    
            <TextBlock Grid.Row="0" Grid.Column="0" Text="Number Textbox" />
            <TextBlock Grid.Row="1" Grid.Column="0" Text="Email Textbox" />
            <TextBlock Grid.Row="2" Grid.Column="0" Text="Username Textbox" />
    
            <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Number,Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}"/>
            <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Email,Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}"/>
            <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Username,Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}"/>
        </Grid>
    </UserControl>
    

    DataModel.cs:

    public class DataModel : INotifyPropertyChanged
        {
            private string _number;
            [Range(0 ,1000, ErrorMessage = "Number must be between 0 and 1000")]
            public string Number
            {
                get { return _number; }
                set {
                    Validator.ValidateProperty(value, new ValidationContext(this, null, null) { MemberName = "Number" });
                    _number = value;
                    RaisePropertyChanged("Number");
                }
            }
    
    
            private string _email;
    
            [RegularExpression("[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}", ErrorMessage = "Invalid Email")]
            public string Email
            {
                get { return _email; }
                set
                {
                    Validator.ValidateProperty(value, new ValidationContext(this, null, null) { MemberName = "Email" });
                    _email = value;
                    RaisePropertyChanged("Email");
                }
            }
    
            private string _username;
    
            [Required(ErrorMessage = "User Name is Required")]
            [StringLength(12, MinimumLength = 6, ErrorMessage = "User Name must be in between 6 to 12 Characters")]
            public string Username
            {
                get { return _username; }
                set
                {
                    Validator.ValidateProperty(value, new ValidationContext(this, null, null) { MemberName = "UserName" });
                    _username = value;
                    RaisePropertyChanged("Username");
                }
            }
    
            public event PropertyChangedEventHandler PropertyChanged;
            public void RaisePropertyChanged(string propertyName)
            {
                PropertyChangedEventHandler handler = PropertyChanged;
                if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
            }
    
    
        }
    

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i need to write simple Minesweeper game in asp.net (Only for learning purposes
As a part of our application I need to write simple workflow system which
I need to write a 'simple' util to convert from ASCII to EBCDIC? The
I need to write a simple command-line application in Java. It would be nice
I need to write a simple parser to a sort of Domain Specific Language.
I need to write a simple program for work that does the following: read
I need to write a simple program that records all the input from parallel
I need to write a simple C# .NET application to retrieve, update, and insert
I need to write a simple source control system and wonder what algorithm I
I'm using Dev C++ to write a simple C program and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.