Here is the code for your use case, its ready to execute.
i have used 2 listeners, and keeping track of previously selected value in a hidden node.
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="cq:Dialog" modal="{Boolean}true" title="Text" width="800" xtype="dialog"> <items jcr:primaryType="cq:Widget" xtype="tabpanel"> <items jcr:primaryType="cq:WidgetCollection"> <advanced jcr:primaryType="cq:Panel" title="Advanced Properties"> <items jcr:primaryType="cq:WidgetCollection"> <target jcr:primaryType="cq:Widget" fieldDescription="Select target for the url" fieldLabel="Target" name="./target" type="select" xtype="selection"> <options jcr:primaryType="cq:WidgetCollection"> <samewindow jcr:primaryType="cq:Widget" text="Same window" value="_self"/> <newwindow jcr:primaryType="cq:Widget" text="New window" value="_blank"/> </options> <listeners jcr:primaryType="nt:unstructured" selectionchanged="function(comp, val, isChecked) {console.log("selected"+val);d = comp.findParentByType("dialog").getField("./hidevalue"); console.log(d.getValue());x=d.getValue(); if(x==val) { alert("Same value selected"); }}"/> </target> <hidden jcr:primaryType="cq:Widget" name="./hidevalue" xtype="hidden"/> </items> </advanced> </items> </items> <listeners jcr:primaryType="nt:unstructured" beforesubmit="function(dialog){console.log("Closed");d = dialog.getField("./target"); console.log(d.getValue()); h = dialog.getField("./hidevalue"); h.setValue(d.getValue());};"/> </jcr:root>