Expand my Community achievements bar.

Show custom error message on validate property in dialog

Avatar

Level 4

Hi Team,

I am trying to show the custom message on dialog field if not valid using validate property.

validate   string (type)   function(){ var Value = this.getValue(); if(Value.length > 0){ this.markInvalid('Please enter correct value'); return false; } }

Still I am getting the default error message ."Verify the values of the marked field"

PFA

Thanks a lot in advance

9 Replies

Avatar

Level 7

Try the below one for custom error message.

CQ.Ext.Msg.show({
   title:'Save Changes?',
   msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',

icon: CQ.Ext.MessageBox.ERROR,
   buttons: CQ.Ext.Msg.ERROR,
 });

Thanks

Tuhin

Avatar

Level 4

Hi ,

I tried this approach as well its not working, still I see the default message.

I think the problem in this dialog is included as cq:include in another dialog which might not allowing it ?

Thank you

Avatar

Level 7

this below piece code works for me, last one had a typo, if you have copied and pasted that exactly then it might be of some problem.

 

if(Value.length > 0){ 
CQ.Ext.Msg.show({
                    title: 'markInvalid',
                    msg: 'The scheduled end date must be set after the scheduled start date.',
                    icon: CQ.Ext.MessageBox.ERROR,
                    buttons: CQ.Ext.Msg.OK
                });

return false; 
}

Avatar

Level 4

Thank you 

I tried the above approach still its not working .

Thanks

Avatar

Level 7

I think that might be because your listener code is not executing properly.

Please place one alert message inside the if statement to see if it is executing at all.

 

if the alert message from the if statement is not coming try using the below code and see.

 

 function(dialog){ 
 var value = this.findById("jcr:title"); /** replace "jcr:title" with the field name on which you want to validate **/
 if(value.length > 0){ 
 CQ.Ext.Msg.show({
                    title: 'markInvalid',
                    msg: 'The scheduled end date must be set after the scheduled start date.',
                    icon: CQ.Ext.MessageBox.ERROR,
                    buttons: CQ.Ext.Msg.OK
                });

return false; 
 } 
 }

 

Thanks

Tuhin

Avatar

Level 4

Alert message is working but custom message through message box is not working.

Thanks

Avatar

Level 7

Hi Sumit,

 

I am not sure why the custom message is not getting shown in your application. Please view the below community article where a similar kind of implementation is there which is same as above.

https://helpx.adobe.com/experience-manager/using/tips-tricks.html

Thanks

Tuhin

Avatar

Level 10

which xtype do you want to validate in the dialog ?