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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:14:36+00:00 2026-06-08T11:14:36+00:00

I am a beginner with C# and am having some problems with DateTime. I

  • 0

I am a beginner with C# and am having some problems with DateTime.
I do not want to use 3 separate dropdowns or textboxes for date. But I still want to be able to put restrict the user input to the format of the date (dd/mm/yyyy). How can I do that?

Note: I am just a learner so please explain whatever code you write

  • 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-06-08T11:14:38+00:00Added an answer on June 8, 2026 at 11:14 am

    Hi You can use javascript to restrict your date feild.

    See below my code

    Your textbox in aspx page ,

    <asp:Textbox ID="txtDate" runat="server" />

    and use javascript like below

    <script type="text/javascript" language="javascript">
    function ValidateDateOf() {
        DayObj = new Date();
        var txtdate =  document.getElementById('<%=txtDate.ClientID %>').value;
        var arr = txtdate.split("/");
        var leapday = arr[0];
        var leapmonth = arr[1];
        var leapyear = arr[2];
    
        var CurDate = DayObj.getDate();
        var CurYear = DayObj.getFullYear();
        var CurMonth = DayObj.getMonth();
    
        if (leapday == '') {
            alert('day Field is required');
            return false;
        }
        if (leapmonth == '') {
            alert('month Field is required');
            return false;
        }
        if (leapyear == '') {
            alert('year Field is required');
            return false;
        }
        if (parseInt(leapday) > 29) {
            alert('invalid date');
             return false;
        }
        if (!isleap(leapyear)) {
            if (parseInt(leapday) > 28) {
                alert('invalid date');
                return false;
            }
            return true;
        }
        return true;
    }
    
    function isleap(leapyear) {
        var yr = leapyear;
        if ((parseInt(yr) % 4) == 0) {
            if (parseInt(yr) % 100 == 0) {
                if (parseInt(yr) % 400 != 0) {
                    return false;
                }
                if (parseInt(yr) % 400 == 0) {
                    return true;
                }
            }
            if (parseInt(yr) % 100 != 0) {
                return true;
            }
        }
        if ((parseInt(yr) % 4) != 0) {
            return false;
        }
    }
    

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

Sidebar

Related Questions

I'm having some beginner problems setting an FFI struct in Ruby. What I want
I'm a beginner in WSS 3.0 and I'm having some problems with the navigation
I'm a novice/beginner programmer having problems getting some simple client/server C code working. My
I was having some problems with the regex in urls.py (I am a beginner
I'm very new to Objective-C, and am having some beginner issues. I have an
I'm having some trouble indexing data.frames in R. I'm an R beginner. I have
I'm having problems with the following code (I am a beginner in most things
Having some really weird problem and as beginner with c++ I don't know why.
I'm having some trouble removing null values from a 2D array. I'm still a
I'm having some trouble with the following. I'm a beginner, which is probably why.

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.