PHP, SugarCRM, Javascript, Cool Web Apps Developer

Blog

Add form Validation SugarCRM

Posted by swapnil shinde on July 19, 2012 at 1:40 AM

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');

Categories: Jul2012-SugarCRM Help

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

You must be a member to comment on this page. Sign In or Register

3 Comments

Reply prince
2:01 AM on May 18, 2013 
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');
Reply Janusz
2:13 PM on May 23, 2013 
Thank you very much!
Reply Prog3712
1:48 AM on November 26, 2014 
I already prefer the addToValidateCallback function . I can define my validation y return the message i want.
e.g:
addToValidateCallback('EditView', 'field name', 'custom', bool required (true or false), 'your message', customFuncionJS);
Greetings!