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:
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);
if (isvalid) {
result = true;
}
return result;
}
</aui:validator>
We use <aui:validator> tag to do validations.
It allows "name" and "errormessage" attributes
Names it allows are:
- alpha
- alphanum
- date
- digits
- 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.
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);
if (isvalid) {
result = true;
}
return result;
}
</aui:validator>
thx a lot
ReplyDeleteBut i want "+,$" these symbols should not allowed in email address
ReplyDelete