I am trying to implement the validation to Date parameter in Birt. But script is not executing as expected.
Eg:
ParameterName : StartDate Type : String
Validation for Length :
Validation script in beforeFactory :
errorcode=0; var str=params["StartDate"].value; if( str.length != 10 ) { errorcode=1001; }
HTML Text in Report layout:
// Error Codes
var ERR_INVALID_DATE_FORMAT = 1001; var ERR_INVALID_START_DATE_VALUE = 1003; var ERR_INVALID_END_DATE_VALUE = 1004;
// Error Messages var MSG_INVALID_DATE_FORMAT ="Invalid Date Format"; var MSG_INVALID_START_DATE_VALUE ="Invalid start date value"; var MSG_INVALID_END_DATE_VALUE ="Invalid end date value";
switch(errorcode;) { case ERR_INVALID_DATE_FORMAT: alert( MSG_INVALID_DATE_FORMAT ); break;
case ERR_INVALID_START_DATE_VALUE: alert( MSG_INVALID_START_DATE_VALUE ); break;
case ERR_INVALID_END_DATE_VALUE: alert( MSG_INVALID_END_DATE_VALUE ); break;
default: alert(errorcode); }
The switch statement is not able to validate the errorcode and it's not showing the alert message.
Note: Earlier used custom format for date parameter but it's not able to detect the incorrect values for Date like aa/23/20145.
Is there any way to implement these validation?