PHP, SugarCRM, Javascript, Cool Web Apps Developer

Blog

Add form Validation SugarCRM

Posted by swapnil shinde on July 19, 2012 at 1:40 AM Comments comments (3)

Hi,

I have seen and encountered with issues like we need to do a validation that is out of box of SugarCRM.

For e.g. we have addToValidateDateBefore which works or invokes like

if you add it on date1 and to be validated with date 2, then it will work only if date1 is newer than date2, but we need to show error if date 1 is older than date2.

We can do our normal custom coding to verify these dates but question is how do we show errors in Sugar's fashion (a red colored message under field.)

so in your js code of edit view once you need to show error just put 

add_error_style('form name', 'field name', 'your message');

e.g

add_error_style('EditView', 'replan_start_date', 'Replan Date should not be older than Booking Date');