jaws1021
asked on
date format
what is the date validationexpression for format yyyymmdd ? It also should be good for leap year.
yyyyMMdd is this that you want ?
ASKER
yes please
http://regexlib.com/DisplayPatterns.aspx?cattabindex=4&categoryId=5
You will find lots of examples in here.
You will find lots of examples in here.
Plus you can use ASP.NET Compare Validator to validate a date on both Client side (depending on the browser) and it can also be accessed on the server side...
<asp:CompareValidator ID="compareDate" runat="server" ControlToCompare="txtDateT extbox" Operator="DataTypeCheck" Type="Date" ErrorMessage="Chack Date" />
This does format the date as MM/DD/YYYY and I know that you said you wanted it the other way around, but i thought that the Compare Validator is an easy validation tool...
John
<asp:CompareValidator ID="compareDate" runat="server" ControlToCompare="txtDateT
This does format the date as MM/DD/YYYY and I know that you said you wanted it the other way around, but i thought that the Compare Validator is an easy validation tool...
John
ASKER
I am using regular expression validation and I need this format yyyyMMdd . I looked at that link but didn;t help me that much..
Try this one, there aer several on the page:
http://regexlib.com/Search.aspx?k=date%20format
Also, you can reformat the date once you have it in one forma or another.
Using Javascript:
http://www.w3schools.com/jsref/jsref_obj_date.asp
Or VBScript on server side
Year() & "-" & Month() & "-" & Day()
There are a lot of choices once you have the date in a variable...
John
http://regexlib.com/Search.aspx?k=date%20format
Also, you can reformat the date once you have it in one forma or another.
Using Javascript:
http://www.w3schools.com/jsref/jsref_obj_date.asp
Or VBScript on server side
Year() & "-" & Month() & "-" & Day()
There are a lot of choices once you have the date in a variable...
John
protected void Page_Load(object sender, EventArgs e)
{
//DateTime oldString = Convert.ToDateTime("Wed, 5 Sep 2007 07:56:04");
//string newstring=oldString.ToStri ng("yyyy-M M-dd HH:mm:ss");
cmdSignIn.Attributes.Add(" OnClick", "return checkDate('06/09/2007');") ;
}
========================== ==
.ASPX
<script>
function checkDate(value){
var dateregex=/^[ 0]*(\d{1,2})\/(\d{1,2})\/( \d{4,}) *$/;
var match=value.match(daterege x);
if (match) {
var tmpdate=new Date(match[3],parseInt(mat ch[1])-1,m atch[2]);
if (tmpdate.getDate()==parseI nt(match[2 ]) && tmpdate.getFullYear()==par seInt(matc h[3]) && (tmpdate.getMonth()+1)==pa rseInt(mat ch[1])){
alert ( 'Y;')
return true;
}
}
alert ( 'Nope;')
return false;
}
</script>
<form id="form1" runat="server">
<asp:Button ID="cmdSignIn" runat="server" Text ="click me"/>
</form>
Check date using script. i hope thiw will help you
Regards,
M.Raja
{
//DateTime oldString = Convert.ToDateTime("Wed, 5 Sep 2007 07:56:04");
//string newstring=oldString.ToStri
cmdSignIn.Attributes.Add("
}
==========================
.ASPX
<script>
function checkDate(value){
var dateregex=/^[ 0]*(\d{1,2})\/(\d{1,2})\/(
var match=value.match(daterege
if (match) {
var tmpdate=new Date(match[3],parseInt(mat
if (tmpdate.getDate()==parseI
alert ( 'Y;')
return true;
}
}
alert ( 'Nope;')
return false;
}
</script>
<form id="form1" runat="server">
<asp:Button ID="cmdSignIn" runat="server" Text ="click me"/>
</form>
Check date using script. i hope thiw will help you
Regards,
M.Raja
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.