FormValidator

27 views
Skip to first unread message

Mariano

unread,
Mar 10, 2014, 1:11:09 PM3/10/14
to all...@googlegroups.com
Hello, I'm new to all this AUI and Liferay and I have question about it.

If I use the example from http://alloyui.com/examples/form-validator/ in a portlet with Liferay it works fine. But if I change the tags from <form> to <aui:form> and <input> to <aui:input> it doesn't validate. Shouldn't it work all the same?

I have included <%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %> and if I don't use the Validator I can use an aui:form just as it is.

Thanks in advance.

Jonathan Mak

unread,
Mar 11, 2014, 2:00:58 PM3/11/14
to all...@googlegroups.com
Hi Mariano,

By changing the tags from <form> to <aui:form> and <input> to <aui:input> you are now using a taglib in your portlet.  You would need to use <aui:validator> taglib to get the form fields validated if you are using the taglibs.  The benefit of using the taglib is that you no longer need to write Javascript to get the form fields and Alloy to work together/validate.

An example of this is below:

<aui:form method='POST' action="<%=actionURL.toString() %>" name="fm" id="fm">
     <aui:input name="email" >
        <!-- Make the field required.  If the field is empty, form will not submit -->
        <aui:validator name="required" />

        <!-- Only allow valid email addresses in the field -->
        <aui:validator name="email" />
    </aui:input>
</aui:form>

I hope this helps!

Mariano

unread,
Mar 12, 2014, 9:24:47 AM3/12/14
to all...@googlegroups.com
That makes sense. Thank you for your reply!
Reply all
Reply to author
Forward
0 new messages