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 899039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:09:01+00:00 2026-05-15T15:09:01+00:00

Using C# C# Code protected void cusCustom_ServerValidate(object sender, ServerValidateEventArgs e) { if(e.Value.Length == 8)

  • 0

Using C#

C# Code

protected void cusCustom_ServerValidate(object sender, ServerValidateEventArgs e)
{
    if(e.Value.Length == 8)
        e.IsValid = true;
    else
        e.IsValid = false;
}

Page code

<asp:CustomValidator runat="server" id="cusCustom" controltovalidate="txtoedate" onservervalidate="cusCustom_ServerValidate" errormessage="The text must be exactly 8 characters long!" />

The above code is working for the length, but i want to check the date format like this
“yyyy-mm-dd”, for checking this date format, how to change my code.

Need Code 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-15T15:09:02+00:00Added an answer on May 15, 2026 at 3:09 pm

    Well, firstly, your date format isn’t 8 characters long, so you’ll need to fix that to 10. Then your best bet is a DateTime.TryParseExact with the specific format you want to validate.

    DateTime value;
    e.IsValid = DateTime.TryParseExact(e.Value, "yyyy-MM-dd",
        CultureInfo.InvariantCulture, DateTimeStyles.None, out value);
    

    You can get away with InvariantCulture because you are only dealing with the numeric representations of the date parts and are specifying the format exactly.

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

Sidebar

Related Questions

Here’s my code behind: protected void gvviewapproval_RowUpdated(object sender, GridViewUpdatedEventArgs e) { using (SqlConnection cn
I am using the below code protected void lnk_Click(object sender, EventArgs e) { try
I'm using the code below: protected void grdViewCInfo_RowDataBound(object sender, GridViewRowEventArgs e) { MySqlConnection objMycon1
I have a master page with the following code: protected void Page_Init(object sender, EventArgs
I have this code: protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) {
I am using following code in rowdatabound function. Protected Sub gvwMileStone_RowDataBound(ByVal sender As System.Object,
I have the following code: protected void Page_Load(object sender, EventArgs e) { XElement xml
I have the following code: protected void Page_Load(object sender, EventArgs e) { var openId
I have made something like the following code: protected void Page_Load(object sender, EventArgs e)
Here is the code behind: protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { DetailsView1.Visible =

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.