Posts

Showing posts with the label form

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...

Submitting the form with ajax(using alloy UI) i.e with out page refresh

    In rare it may happens, you have to submit the form with out refresh the page (actionURL ) and save the parameters in the DB.    Jus Copy the below code , Here i am using alloy UI to submit the form and here not need to append any parametrs to the URL .you will get the parameters values from request parameters. <portlet:actionURL var="formsubmissionURL" /> <aui:script use="aui-io-request,aui-node" > Liferay.provide(window,'submitForm', function() { var A = AUI(); A.io.request('${formsubmissionURL}',{ method: 'POST', form: { id: '<portlet:namespace />fm' }, on: { success: function(){     }   }   });   }); </aui:script > <aui:form action="#" method="POST" id="fm" name="fm" >      <aui:input type="text" name="name"/>      <aui:button type="submit" value="Save" /...