Posts mit dem Label validation werden angezeigt. Alle Posts anzeigen
Posts mit dem Label validation werden angezeigt. Alle Posts anzeigen

Mittwoch, 6. Februar 2013

CQ5 Dialog Validation

By registering a listener to the beforesubmit event, you can validate a dialog.
... xtype="dialog"> <listeners jcr:primaryType="nt:unstructured" beforesubmit="function(dialog){ // your validation code return isValid; }" /> <items jcr:primaryType="cq:TabPanel"> ...

Serverside Validation

After defining a custom validating servlet, you can put the following code snippet in the beforesubmit area. It is important to call the servlet using async=false, to ensure everything is handled by the same thread.
CQ.Ext.Ajax.request({ method: 'POST', url: '/content.myvalidationservlet.json', async: false, success: function(response){ // do something }, params: { ... } });

Email Address Validation using Regular Expressions

Validating email addresses using a pattern is tough and you should evaluate the impacts of using a too weak/strong pattern. On fightingforalostcause.net I found a good comparison of different patterns, that lists all false positives and true positives for the presented regular expressions.