cq5 - How to make textfield required using listeners -



cq5 - How to make textfield required using listeners -

i have listener on selector hide , show textfield based upon selected value. want implement value show should mandatory fill in. used allowdblank true within listener didn't work. below listener.

function(selection,record,path) { var dialog=selection.findparentbytype('panel'); var email = dialog.getcomponent('email1'); var url = dialog.getcomponent('url1'); if(record == 'email'){ url.hide(); url.setvalue(""); email.show(); //how create email manadory } if(record == 'link'){ email.hide(); email.setvalue(""); url.show(); } }

thanks

i've used "allowblank" on selectionchanged listener. i've used toggle fields required/not-required many times. here's working code adapted illustration (i omitted parts don't relate required field). using getfield method instead of getcomponent well:

dialog:

<type jcr:primarytype="cq:widget" fieldlabel="type" name="./type" type="radio" xtype="selection"> <options jcr:primarytype="cq:widgetcollection"> <email jcr:primarytype="nt:unstructured" text="email" value="email"/> <url jcr:primarytype="nt:unstructured" text="url" value="url"/> </options> <listeners jcr:primarytype="nt:unstructured" selectionchanged="function(field,value) { mydialog.setrequired(field,value); }"/> </type>

listener javascript:

mydialog.setrequired = function(field,value) { var dialog = field.findparentbytype("dialog"), email = dialog.getfield('./email1'); if('url' == value) { email.allowblank = true; }else{ email.allowblank = false; } };

cq5 aem

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -