Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Validating Date Parameter
Swathi1985
I have a report where in i allow the user to enter date in the format yyyy-MM-dd.
I want to validate the date and prevent user from entering the report if date is invalid (eg. 2010-26-43).
Can you please provide sample code on how to achieve this using script in BIRT?
Thanks in advance.
Find more posts tagged with
Comments
bgbaird
Check out
http://www.birt-exchange.org/org/forum/index.php/topic/25634-date-parameter/
Swathi1985
<blockquote class='ipsBlockquote' data-author="'bgbaird'" data-cid="103427" data-time="1339781046" data-date="15 June 2012 - 10:24 AM"><p>
Check out <a class='bbc_url' href='
http://www.birt-exchange.org/org/forum/index.php/topic/25634-date-parameter/'>http://www.birt-exchange.org/org/forum/index.php/topic/25634-date-parameter/</a><br
/></p></blockquote>
Swathi1985
The link you provided talks about comparing two dates. What i want is how to validate if the date entered is
valid in the first place. You know what i am saying.
My Date format is yyyy-MM-dd.
I want to notify user if he enters some invalid date like say
2012-25-40
bgbaird
That is already a function of the parameter object.
If you have set the Data Type to Date or Date Time, only valid formats will validate.
This required no additional validation processing.
In the attached design, type "kjt56" in the parameter field, and see the failure.
If you need to validate a date outside of the parameter object:
var timestamp=Date.parse(params["dateValidation"].value);
isNaN(timestamp);
Brian
Swathi1985
<blockquote class='ipsBlockquote' data-author="'Swathi1985'" data-cid="103439" data-time="1339786750" data-date="15 June 2012 - 11:59 AM"><p>
The link you provided talks about comparing two dates. What i want is how to validate if the date entered is <br />
valid in the first place. You know what i am saying.<br />
My Date format is yyyy-MM-dd.<br />
<br />
I want to notify user if he enters some invalid date like say<br />
2012-25-40<br /></p></blockquote>
Swathi1985
Please try to enter the date as 2012-19-56 in the report you have attached.
Though it is invalid, it ll be displayed as Aug 25, 2013 in the report.
I was expecting it to error out actually but that's not happening.
Swathi1985
<blockquote class='ipsBlockquote' data-author="'Swathi1985'" data-cid="103474" data-time="1339797956" data-date="15 June 2012 - 03:05 PM"><p>
Please try to enter the date as 2012-19-56 in the report you have attached.<br />
Though it is invalid, it ll be displayed as Aug 25, 2013 in the report.<br />
I was expecting it to error out actually but that's not happening.<br /></p></blockquote>
<br />
<br />
Any updates on this pls !
bgbaird
Swathi, I entered the string you suggested and for me, it failed validation just as it should.
What version of BIRT, and what IDE?