Foros de discusión
AUI form either of the field required
gary b, modificado hace 6 años.
AUI form either of the field required
Junior Member Mensajes: 81 Fecha de incorporación: 2/02/13 Mensajes recientes
I have two aui input fields , user need to enter either of the field before submitting the form. for example user either need to enter his username or Userid,both fields can't be empty.
How to achieve this? Please help.
TIA
How to achieve this? Please help.
TIA
Andrew Jardine, modificado hace 6 años.
RE: AUI form either of the field required
Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
Hi Gary,
The same way you would if you didn't have AUI? You have your form, you wire the form submite action such that it calls a JS function, you use the JS function to get your form fields and validate that both are not empty. You could do this with an AUI script very easily
.. something like that perhaps? I'm just coding that off the cuff, so no guarantees on syntax or anything but the point is that you solve this JS riddle the same way you solve any JS riddle. You don't even have to use AUI if you don't want to. Plenty of folks out there still gravitate towards jQuery for such puzzles.
The same way you would if you didn't have AUI? You have your form, you wire the form submite action such that it calls a JS function, you use the JS function to get your form fields and validate that both are not empty. You could do this with an AUI script very easily
<aui:script>
function validate() {
var input1Node = A.one('#input1id');
var input2Node = A.one('#input2id');
if (input1Node && input2Node) {
if (input1Node.val() || input2Node.val()) {
return true;
}
else {
return false;
}
}
}
</aui:script>
.. something like that perhaps? I'm just coding that off the cuff, so no guarantees on syntax or anything but the point is that you solve this JS riddle the same way you solve any JS riddle. You don't even have to use AUI if you don't want to. Plenty of folks out there still gravitate towards jQuery for such puzzles.