Sample example


<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>

<aui:form name="fm2" action="" method="post">
<table>
<tr>
<td>
<aui:input name="number" value='${number}' label="Enter number#" inlineLabel="left"/>
</td>
<td>
<aui:button type="submit" name="numberSearch" value="Number Search" />
</td>
</tr>
</table>
</aui:form>


<aui:script>
AUI().ready('aui-form-validator', 'aui-overlay-context-panel', function(A) {

// Extending Alloy Default values for FormValidator STRINGS and RULES
A.mix(
YUI.AUI.defaults.FormValidator.STRINGS,
{
customRule: 'Please enter number only.'
},
true
);

A.mix(
YUI.AUI.defaults.FormValidator.RULES,
{
customRule: function(val, fieldNode, ruleValue) {
return (!isNaN(val));
}
},
true
);

var validator1 = new A.FormValidator({
boundingBox: '#fm2',
validateOnBlur: true,
selectText: true,
rules: {
<portlet:namespace />number: {
required: true,
rangeLength: ['4','10'],
customRule:true
}
},
fieldStrings: {
<portlet:namespace />number: {
required: ' Number is a required field'
}

on: {
submit: function(event) {
var formEvent = event.validator.formEvent;
}
}
});
});

</aui:script>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: