You can set the focus to a selected field with rules.
Giving a list of controls as an array and the name of a target control:
If the target control has error, we set the focus to this control, otherwise we should set the focus to the next non-disabled field in the list.
|
|
// Create three fields
document.getElementById("ux-focus-example01").innerHTML =
ui.input( "Field 1", "ux-focus01", "" )
+ui.button("ux-focus01b1","Set error",{link:"javascript:ux.set('ux-focus01','error')"})
+ui.button("ux-focus01b2","Set clear",{link:"javascript:ux.set('ux-focus01','clear')"})
+'<br>'
+ui.input( "Field 2", "ux-focus02", "" )
+ui.button("ux-focus02b1","Set disabled",{link:"javascript:ux.set('ux-focus02','disabled')"})
+ui.button("ux-focus02b2","Set clear",{link:"javascript:ux.set('ux-focus02','clear')"})
+'<br>'
+ui.input( "Field 3", "ux-focus03", "" )
+'<br>'
+'<br>'
+ui.button("ux-focus01b1","ux.focus(next after =<br> 'Field 1')",{link:"javascript:ux.focus(['ux-focus01','ux-focus02','ux-focus03'],'ux-focus01')"});
Preview: (Try to set error/disable and then click Set Focus)
In the Preview section of the example you can try using the button controls "Set error" and "Set clear"
|