ValidateScript

Specifies the server-side validation JavaScript to run when the entry is executed in save mode.

The script sets the Valid variable to one of these values:

  • true. Indicates that validation has succeeded.
  • false. Indicates that validation has failed. In this case, the screen remains in edit mode and displays an error message. An orange question mark is displayed next to the field whose validation has failed.
Values

JavaScript to run. This must be a string value. You can set the ErrorStr variable in your script to display a custom error message.

Examples

r = CRM.FindRecord('Company','Comp_companyid=30');
EG = CRM.GetBlock('companyboxlong');
NewE = EG.GetBlock('comp_name');
NewE.ValidateScript = "Valid = (comp_name.value != '');if (!Valid) ErrorStr = 'Please correct the highlighted entries';";
CRM.AddContent(EG.Execute(r));
Response.Write(CRM.GetPage());

The script in this example sets the Valid variable to true if the comp_name field is not empty (comp_name.value != '').
If the comp_name field is empty, the following error message is displayed: "Please correct the highlighted entries".