Posts

Showing posts with the label field

Form Validation In Liferay -- Client Side validation

In Liferay we can do client side validation very easily.  We use <aui:validator>  tag to do validations. It allows "name" and "errormessage" attributes Names it allows are: alpha alphanum date digits email equalTo number acceptFiles min minLength max maxLength range rangeLength required url custom Here custom is use to give custom validations , Below Exampleis the custom validation for email validation .In Liferay for email sometimes its is not working. So i am writing the custom validation.  Just Copy & paste the code and try it will perfectly works <aui:validator name=" custom " errorMessage="Please enter valid email address">       function (val, fieldNode, ruleValue) {           var result = false;         var emailRegexStr = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;         var isvalid = emailRegexStr.test(val...

Focusing the form field in Liferay

  Whenever we create from in liferay ,it is required cursor to focus on the first field.   Suppose we can have form like this   <aui:from name="fm" method="post" action="${updateActionURL}">             <aui:input  name="title" label = "Title"/>        <aui:input  name="desc" label = "Desc"/>       <aui:button type="submit" value ="save"/> <.aui:form>  If we think title should be highlited on page load , following script is also required. <aui:script> Liferay.Util.focusFormField(document.<portlet:namespace/>fm.<portlet:namespace/>title); </aui:script> Deploy your project and refresh your page . We can see the first field is highlighted. These source are avaliable in the follwing path.       portal-web/docroot/html/js/liferay