Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Validate Date Input parameter
techsavvy
Hi,
We have a date input parameter with custom format dd-MMM-yyyy(30-Sep-2010),when the user enters input like '30/Sep/2010',ValidationValueException is obtained.
I tried some script in validate() method but not working.
Could you please suggest how to display a custom message 'Illegal Date format'.
Thanks
Find more posts tagged with
Comments
JasonW
You could always change the type to string and do your own validation. Take a look at the attached report. Notice if the date fails the table in the report is dropped. (look at beforeFactory script and the contents of the text element at the top of the report).
Jason
JasonW
Example report
techsavvy
Thanks a lot.. :-)
Its working perfectly.I have some queries...Could you please clarify the below doubts..
1) Why do we put the validation code in the 'beforeFactory()' instead of the 'validate()' method of the parameters.
2) Also,in the HTML txt,we use <VALUE-OF/> tag which is not an actual HTML tag,where do we find related docs about the usage of similar BIRT tags.
Thanks.
JasonW
The validate method can return true or false but currently does not support a specific message, that why I moved it to beforeFactory. The value-of tag is specific to the text element to allow you to integrate the value of generation data within your html( or client side js functions) for the output. There is some data on the text element in the developers guide in the help but I am not certain it details the value-of tag.
Jason
SureshMart
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="69023" data-time="1286205117" data-date="04 October 2010 - 08:11 AM"><p>
The validate method can return true or false but currently does not support a specific message, that why I moved it to beforeFactory. The value-of tag is specific to the text element to allow you to integrate the value of generation data within your html( or client side js functions) for the output. There is some data on the text element in the developers guide in the help but I am not certain it details the value-of tag.<br />
<br />
Jason<br /></p></blockquote>
<br />
<br />
Hi I am trying to do the same for the date for (dd-MMM-yyyy). But when I pass 00-Sep-2010 it doesnt go to the catch block rather it treats as a valid date <br />
When I try to print this value sdf.parse(params["rpLimitExpiryDate"]); it shows me 31-Aug-2010. Can you please help me on this.
pravinpoc
<p>Hi,</p>
<p>We got a problem.</p>
<p> </p>
<p>importPackage(Packages.java.lang);<br>
importPackage(Packages.java.text);<br>
sdf = new SimpleDateFormat("MM/dd/yyyy"); <br>
testStartDate = null;<br><br>
dateerror=false; <br>
try <br>
{ <br>
testStartDate = sdf.parse(params["StartDate"]); <br><br>
dataerror=false;<br>
} <br>
catch (e) <br>
{ <br>
errorMessage = "the date you provided is in an invalid date"; <br>
eee = e;<br>
dateerror=true;<br>
}</p>
<p> </p>
<p>Though we are passing the correct date format i.e,12/10/2014 for startdate .it thowing the error</p>