.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

Asp.net Javascript Validation dd/mm/yyyy format

Posted By:      Posted Date: August 25, 2010    Points: 0   Category :ASP.Net

Hi experts,

 I am trying to validate two textbox (fromdate,todate)

should alert a message when Fromdate is more than Todate

I could find only mm/dd/yyyy format in most of google search.

please give me a script or assist how to do this.



View Complete Post

More Related Resource Links

decimal value validation and round off by javascript

The article decimal value validation and round off by javascript was added by hiral.hapani on Wednesday, June 02, 2010.

Hi All, I have createdone javascript by which you canvalidate a decimal value of any textbox for which you want. By thisjavascriptwecan bind user to enter only digits in textbox. and when he will enter any decimal value javascript will do round off it

How to convert Date format from dd/MM/yyyy to mm/dd/yyyy in asp.net



         I am using a text box which captures the date from the datepicker and displays in dd/MM/yyyy format in asp.net using C#

When i try to pass this text box value into the DatTime variable i am getting the error as

"String was not recognized as a valid DateTime. "


my code goes like this

DateTime dt;




i tried to use Conver.ToDateTime() function but the same error is croping up..


Can any one plz suggest me on this.....Thnks in advance

Insert DATE to database (format 'YYYY-MM-DD')

How can I insert BIRTHDATE into column in 'YYYY-MM-DD' format. This is my code, can anyone edit my code? Tnx String = "INSERT into concfile VALUES(BIRTHDATE('" & DateTimePicker1.Text & "', 'YYYY-MM-DD'))"

how can I make field with date in format: dd/mm/yyyy ?

I have in model:[DisplayName("Publication date")] [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)] [Required(ErrorMessage = "Publication date is required.")] public DateTime publication_date { get; set; } And in view:<div> <%: Html.LabelFor(model => model.publication_date) %> </div> <div> <%: Html.TextBoxFor(model => model.publication_date, new { @class = "datepicker" })%> <%: Html.ValidationMessageFor(model => model.publication_date) %> </div> But when I write in this field date: 30/11/2009 I see validation error: The value '30/11/2009' is not valid for publication_date.

Javascript FromDate to Date Validation Help!

Hi,I want to check fromdate and todate in dd/mm/yyyy.The code below mentioned works perfect for single textbox(fromdate) ,but when tried to do for todate(textbox) it doesnot work properly.From Date Should not be greater than ToDate.Please Help.Below is the code:<html><head><title>Date Example</title><script type="text/javascript">    function isValidDate(sText) {        var reDate = /(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20\d{2})/;        return reDate.test(sText);    }    function validate() {        var oInput1 = document.getElementById("txt1");        if (isValidDate(oInput1.value)) {            alert("Valid");        } else {            alert("Invalid!");        }    }</script></head><body>    <P>Date: <input type="

Javascript numbers only, & format it to Decimal

Hello Experts, I need some help guys ;( I want some javascript code that make sure that end user must enter only numbers on textbox (currency,number), no characters, also typed number will be formated to be decimal number, I mean if user type (22222), javascript should format the number to be (22,222.0) javascript function should be called while end user typing on Textbox. so if he enter character, then the character should be removed automatically. I read many posts that talked about this, but most of them are using the onkeypress(event), so if the user paste the text that code will not work. Please help me guys, I need this urgent

javascript for field validation on a textbox...

I'm looking at doing the validation for the email in javascript since we have asp.net 1.1. I can get it to just alert fine, but once I add the return validation it doesn't fire. Me.ImageButton2.Attributes.Add("onclick", "return validation(this);") <script language="JavaScript"> <!-- function validation () { var test=""; test = document.ticketForm.emailAddress.value; if (test == "xyz") { alert(test); return false; // validation failed } --> </script>

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.

Validation for dd mm yyyy dropdown list

Hi i have a form which asks for date of birth.please find below the code. <asp:DropDownList ID="ddlDay" runat="server"> </asp:DropDownList> &nbsp;<asp:DropDownList ID="ddlMonth" runat="server"> </asp:DropDownList> &nbsp;<asp:DropDownList ID="ddlYear" runat="server"> </asp:DropDownList> asp:CustomValidator ID="valDate" Text="*" runat="server"      ControlToValidate="ddlDay"  ValidationGroup="Group1" OnServerValidate="valDate_ServerValidate" ClientValidationFunction="valDate_ClientValidate"  ErrorMessage="Please enter a valid date of birth" Display="Dynamic" ForeColor=""  CssClass="validatorText" /> The dropdownlist is populated in code behind. The client and server validation code is,        function valDate_ClientValidate(source, args) {            var dd_id = document.getElementById("<%=ddlDay.ClientID %>");            var mm_id = document.getElementById("<%=ddlMonth.ClientID %>");   &nb

format date yyyy-MM-dd and remove 00:00:00

HiI have a very simple question.I retrive a date from my database and save it in a date variable Dim ShowDate As Date = dt.Rows(I)("ShowDate")The date look like this "2010-09-11 09:48:00"now i just want to format it so it only shows the date "2010-09-11"I have tried the following ShowDate = ShowDate.ToString("yyyy-MM-dd")but that returns "2010-09-11 00:00:00"any idea what I am doing wrong?

is there any way to work with date in this format: dd/MM/yyyy hh:mm

hi is there any way to work with date in this format: `dd/MM/yyyy hh:mm` (without second) i see only this format: `dd/MM/yyyy hh:mm:ss` i need that i can see in this format and to run search between date & time in this format i work on access-2007 and C# thank's in advance

radiobutton validation using javascript

hi' i have two radiobuttons and a button.On button click i have to validate whether the radiobutton is selected or not. I tried the following,but it is not working.pls help.<asp:RadioButton  runat="server" ID="rbyes" Text="Yes"  visible="true" GroupName="a"  /> <asp:RadioButton  runat="server" ID="rbno" Text="No" visible="true" GroupName="a" /> <asp:Button  ID="btnOk" runat="server" Text="OK" OnClick="btnOk_Click"  OnClientClick="return selectRadioButton();"/>function selectRadioButton(){var y=document.getElementById("ctl00_ContentPlaceHolder1_rbyes");var n=document.getElementById("ctl00_ContentPlaceHolder1_rbno");if(y.checked==false && n.checked==false){alert(Please select Yes/No");return false;}return true;}

Validation is not working in Custom List Form using JavaScript ddwrt:GenFireServerEvent()

Hii am creating custom New form for a list using sharepoint designer. i have added the below button for sumbit<input name="Submit1" type="submit" value="Submit" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={http://myserver/Lists/VTest/AllItems.aspx}')}" />                <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp;                                    </xsl:text><input name="Submit2" type="submit" value="Cancel" onclick="javascript: {ddwrt:GenFireServerEvent('__redirect={http://myserver/Lists/VTest/AllItems.aspx}')}" />the problem is the validation is not working properly. it submits the page without entering values for the required fields.particularly the validation is not working for DateFields.let me know what is the problem here. is it a Bug?muthu

Delaying clientside validation Javascript


For performance reasons, I usually put all my javascripts at the end of my html page.

However, Html.EnableClientValidation() always generates client side validation script after the form in the middle of the document

Is there anything I can do to change this?

What if the MVC team add a DEFER attribute to the generated javascript validation script

so the generated script should like

<script type="text/javascript" defer="defer">
if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; }

validation group creation using javascript


Hi I want to create a validation group using javascript.

How can I do that? 

Date format not working? {0:dd/MM/yyyy}


Hi I have a date field bound to a textbox in my DetailsView.

The format for the bound field is like so: {0:dd/MM/yyyy} and even the sample displayed in the properties dialog shows the date like so: 17/10/2007

Yet when I run the form, the date is shown like this 17.10.2007.  Is there any reason for this?

beginner validation: jquery vs javascript vs codebehind




I've a webform that has around 10 textboxes that are filled with information from an event trigered by combobox.  so far so good.  The thing is that I need  that some textboxes should be validated against the sum of values of others,  and according to that assign given values.  Other textboxes should have a value according to those sum and datefield values.  I haven't found validation controls for asp.net so I assume that I should to it with javascript or jquery.  My concern as asp.net beginner is what happens if the user disables javascript?  If I make it with codebehind I'll have to refresh the page many times as I have many controls to validate.  What can I do ?


thanks in advance.



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