validation,liferay,liferay-6,liferay-aui , customize error message for required field with <aui:select > in liferay


customize error message for required field with in liferay

Question:

Tag: validation,liferay,liferay-6,liferay-aui

I'm trying to validate a required Select option with aui.

for input fields the code below works without any issue :

<aui:input name="name" value="${name}" label="name">
     <aui:validator name="required" errorMessage="your-message-here"></aui:validator>
</aui:input>

But with Select option field, I cannot customise the required error message :

for example :

<aui:select required="true" label="field.label" id="id" name="name" useNamespace="false">
    <aui:option value="" label="first.option" selected="option1"/>
    <aui:option value="" label="second.option" selected="option2"/>
    <aui:option value="" label="third.option" selected="option3"/>

</aui:select>

My Question is : How can I customize the error message for required field in <aui:Select>

Thanks .


Answer:

You can validate an aui:select with custom message as following (Tested Code):

HTML

<aui:form method="post" name="fm">  
    <aui:select name="sampleDropdown" label="">
        <aui:option selected="true" value="">Select an Option</aui:option>
        <aui:option value="1">Option 1</aui:option>
        <aui:option value="2">Option 2</aui:option>
        <aui:option value="3">Option 3</aui:option>
    </aui:select>

    <aui:button value="Save" type="submit"></aui:button>    
<aui:form>

Script:

AUI().ready('alloy-node', 'aui-form-validator', function(A) {
    var formValidator = new A.FormValidator({
        boundingBox: document.<portlet:namespace />fm,
        rules: {
            <portlet:namespace />sampleDropdown: {
                required: true
            }
        },
        fieldStrings: {
            <portlet:namespace />sampleDropdown: {
                required: 'Hey, can\'t leave this unselected.'
            }
        },
        on: {
            validateField: function(event) {},
            validField: function(event) {},
            errorField: function(event) {},
            submitError: function(event) {
                var errors = event.validator.errors;
                event.preventDefault();
            },
            submit: function(event) {
                return false;
            }
        }
    });
});

Might this snippet be helpful for you.


Related:


In liferay market place, I am unable to submit the project


liferay,liferay-6
In Liferay market place i am stuck at the place "Upload Liferay Plugin Packages " When ever i am trying to upload a war file Please help me to short it out :)...

How to conditionally invoke spring validators


java,spring,validation
I have a model like below. Existing code already has validations on individual properties. Now I have a requirement to ignore existing validations on billing_country and address if buyer.method is foo. I was thinking I could have a custom validator at buyer level, check for method and invoke validations only...

Seeding fails validation for nested tables (validates_presence_of)


ruby-on-rails,ruby,validation,ruby-on-rails-4,associations
An Organization model has a 1:many association with a User model. I have the following validation in my User model file: belongs_to :organization validates_presence_of :organization_id, :unless => 'usertype==1' If usertype is 1, it means the user will have no organization associated to it. For a different usertype the presence of...

How to use javascript to validate the input field for restricting numbers only and setting the range as maximum and minimum


javascript,html,angularjs,forms,validation
On event change the overflow value must get rejected. I have an input box in my form, where I want to restrict the user to enter only the numbers between 0 and 99999 only. But I don't want to disable the tab button functionality. The below code is working fine...

Verifying whether a decimal value is a valid [closed]


ruby,string,validation
I want to verify the numbers after a given decimal. Values above 10 should be considered as invalid. I would need a regex command to verify. For example: Input: Expected response 0.005: valid 1.003: not valid 1.04: valid I tried the following regex, but it doesn't give me the expected...

password check directive elem.add error


javascript,angularjs,validation,events,angularjs-directive
I'm making a password checking directive to ensure password and confirm_password fields are the same: angular .module('myModule') .directive('pwCheck', function() { return { require: 'ngModel', link: function (scope, elem, attrs, ctrl) { var password = "#" + attrs.pwCheck; elem.add(password).on('keyup', function() { scope.$apply(function () { ctrl.$setValidity('pwmatch', elem.val() === $(password).val()); }); }); }...

How to make a valid
  • link

  • html,css,validation
    I'm trying to make an unordered list where the list items are links, not just the text inside them. But this is not valid. When checking my code with https://validator.w3.org/check I receive the message Element a not allowed as child of element ul in this context. This is the code:...

    Input validation setTimeout in ReactJS


    javascript,css,validation,reactjs,ecmascript-6
    I have a component that renders with className="error" or classname="" depending on whether the input is valid or not. This way in CSS I can simply do .error { background: red; }. The validity of the input is determined by the isValidNumber(..) function. However, right now the problem I'm having...

    How can I change the zIndex attribute of aui-datepicker in Liferay Portlet 6.2


    datepicker,liferay,z-index,liferay-aui,alloy-ui
    I have discoveder one problem with date field in portlet in LF 6.2. The problem is that after clicking on the input field, the datepicker is displaying, but with zIndex=0, that means it is under the portlet. If I change on firebug that parameter to 1, everything is OK. I...

    How to create service builder for liferay plugin project with maven


    liferay,liferay-ide,liferay-service-builder
    I have Already create Liferay Plugin project. and maven install also over. it gives ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] --------------------------------------------------------------------- [INFO] Total time: 1:29.773s [INFO] Finished at: Wed Jun 17 15:46:10 IST 2015 [INFO] Final Memory: 34M/151M [INFO] -----------------------------. But unable to add service builder. When i try to add...

    HTML vs. JavaScript form validation [duplicate]


    javascript,jquery,html,html5,validation
    This question already has an answer here: JavaScript: client-side vs. server-side validation 11 answers I am new to front end web development and am making a small application where I want to validate that the user has in fact entered a valid URL. At first thought I figured I...

    What is a reliable isnumeric() function for python 3?


    python,regex,validation,python-3.x,isnumeric
    I am attempting to do what should be very simple and check to see if a value in an Entry field is a valid and real number. The str.isnumeric() method does not account for "-" negative numbers, or "." decimal numbers. I tried writing a function for this: def IsNumeric(self,...

    how to use validationResover


    validation,typo3-flow
    Like shown here I want to use the validationResolver to dynamically validate user inputs in my App. Therefore I want to proove, if a condition is true in my controller. If the condition is true, I want to validate with an own validator. For that I tried that: public function...

    How manage styles in Vaadin portlet in Liferay


    css3,liferay,vaadin,portlet
    I have a Portlet, where is used Valo theme. Most graphical components are displayed properly, but TextField not. It should have rounded border radius and height should be about 35px. It has normally about 15px and the field is angular. When I narrow width of browser window to about 200px...

    MVC 5 - Validate a specific field on client-side


    javascript,jquery,asp.net-mvc,validation,asp.net-mvc-5
    I want to populate a city/state drop down list based on the postal code a user types into a textbox. So when the text changes, I'm going to make an ajax call to retrieve the data. However, I only want to perform that ajax request for valid postal codes. The...

    Cons of a liferay cms while website development using Community Edition


    content-management-system,liferay
    I am new to LIFERAY CMS. i need cons of a liferay cms i.e., difficulties faced while developing and using liferay cms. can you please list cons of liferay cms.

    Yii2 required validation on update


    php,validation,yii2
    I've Yii2 form containing form fields depending on action of page. Ex. Few fields appears when then action is create and few appears when action is update. I want to add required validation based on this scenario. Ex. <?= $form->field($model, 'unique_identifier')->textInput(['maxlength' => 45]) ?> I am showing this field only...

    Is there a shorter/better way to validate request params?


    python,validation,python-2.7,flask,werkzeug
    I keep repeating blocks like this to validate request params. Is there a shorter/better way to implement this? count = request.args.get('count', DEFAULT_COUNT) if count: try: count = int(count) except ValueError: count = DEFAULT_COUNT ...

    Validating IP never succeeds


    java,android,validation,ip,matcher
    The user enters an IP address in a EditTextPreference and I try to validate the IP with this code: private EditTextPreference ipPref; private Matcher matcher; private SharedPreferences settings; private final Pattern IP_ADDRESS = Pattern.compile( "((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]" + "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]" + "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}" + "|[1-9][0-9]|[0-9]))"); @Override public void onCreate(Bundle...

    Lifefay freemarker ADT: methods unavailable?


    java,liferay,liferay-6,freemarker
    I'm trying to work on some ADT for asset publisher (Documents and Media type), but I often have a message telling me that : Expression assetRenderer.getDataRepositoryId is undefined or Expression assetRenderer.getFileEntryId is undefined I found some threads where people said that we must add velocity.engine.restricted.classes= velocity.engine.restricted.variables= freemarker.engine.restricted.classes= freemarker.engine.restricted.variables= in portal-ext.properties...

    Veridis Biometrics SDK validating with strings


    .net,validation,biometrics
    I'm sorry to make a long introduction, but this is what I have done so far: Downloaded the SDK; Read the manual ; Followed the sample project they patched with the SDK. But, the thing is, I already had another biometric solution working and it used to save all hash...

    Restrict angular form submit on mobile


    angularjs,validation
    I have HTML form with angular validation and it shouldn't be submitted unless $valid form state is true. <form name="searchForm" action="/Search" method="get" novalidate> <input name="keywords" required type="search" ng-model="form.keywords"> <button type="submit" ng-disabled="searchForm.$invalid">Go</button> </form> ng-disabled directive prevents from submitting invalid form for desktop or mobile emulator. But if I use screen keyboard...

    Check if the number entered is in array, otherwise add to the array


    java,arrays,validation,input,user
    The user will enter the size of the array and its values. If the entered value exists, the user must enter a different number. I can't seem to construct the proper code to check if the inserted value exists. public static void main(String[] args) { String holder="", s; int size;...

    Javascript/jQuery form validation


    javascript,jquery,forms,validation
    I got most of this form validation to work properly but the only issue is that when the form detects an error on submit and the user corrects the mistake, the error text won't go away. This can be confusing for the user but I can't seem to figure out...

    Regular expression to validate US phone number with Custom validations


    regex,validation
    I want to create regular expression to validate US phone numbers, which will validate below need: 333 (till 1 to 3 digits) 333-3 (3 digits + 1 hyphen + 1 to 3 digit) 333-333-3333 (3 digits + 1 hyphen + 3 digit + 1 hyphen + 1 to 4 digits)...

    how to get validated the associated attributes? rails4


    ruby-on-rails,validation
    I am using rails4. I have a model, lets say human. Human has nested model Man. Man has attributes Name, Address, Number. I am trying to make an api in which i am not able to validate associated attributes. I was able to validate the man by using validates_associated, But...

    Using JavaScript or JQuery to clear a file upload field if the file selected is not a certain type [duplicate]


    javascript,jquery,html,validation,file-upload
    This question already has an answer here: Limit file format when using <input type=“file”>? 8 answers I have essentially re-skinned a file-upload form field. <input id="uploadFile" placeholder="Choose File" disabled="disabled" /> <div class="fileUpload btn btn-primary"> <span>Upload</span> <input id="uploadBtn" type="file" class="upload" /> </div> .fileUpload { position: relative; overflow: hidden; margin: 10px;...

    Codeigniter Form Validation Rule for match (password)


    php,forms,codeigniter,validation
    I am trying to write Form validation rules in my Controller to submit Change Password form in which I am checking the old password too. I am getting the old password(current) from db and placing it in a hidden input field. My Rules are simple and are given below $config=array(...

    Correct PHP contact form syntax? [duplicate]


    php,forms,validation
    This question already has an answer here: PHP: “Notice: Undefined variable” and “Notice: Undefined index” 11 answers I am trying to follow a PHP contact form tutorial from here! Seems pretty simple and I'm completely new to PHP. However, when running my project, I get so many "Notice" messages...

    How to validate non-db attributes on an ActiveRecord model?


    ruby-on-rails,validation,activerecord
    I have the following class: class Instance < ActiveRecord::Base attr_accessor :resolution validates_format_of :resolution, with: /\A\d+x{1}\d+\d/ def resolution=(res) validate! (set the resolution etc) end def resolution (get the resolution and return) end end The resolution attribute is not stored in the database, but is a transient property of the instance. When...

    Validation in JSF


    java,regex,validation
    I'm trying to implement the Validation of a form but it don't accept when I fill in numbers or characters. This is my login.xhtml <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:c="http://xmlns.jcp.org/jsp/jstl/core" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core"> <h:body>...

    Dynamic annotation/attribute values


    c#,validation,annotations,attributes
    I run into a problem using data annotations in c#. I am using custom required and range attributes and I want to set an object as the error message. [MyOwnRequired(ErrorCode=GlobalMessages.Message01] public string Description { get; set; } The problem is that I do have a class holding several objects (GlobalMessages.Message01,...

    MVC HTML Helpers: Get all validation attributes


    c#,asp.net-mvc,validation,html-helper
    When it comes to making custom helpers, how can we get the value for the validation attributes (client-side validation)? for example the built in helpers do something like this: <label class="control-label " for="Starts">Starts</label> <span class="field-validation-valid text-danger" data-valmsg-for="Starts" data-valmsg-replace="true"></span> <input class="form-control text-box single-line" data-val="true" data-val-date="The field Starts must be a date."...

    Enum validation in Rails 4.2 doesn't work


    ruby-on-rails,validation,enums
    My User model looks similar to this: class User < ActiveRecord::Base enum type: [:admin, :reviewer, :super_admin ] validates :type, presence: true validates :type, inclusion: { in: User.types.keys } end When I submit anything outside the enum values, the validation doesn't stop the code from running, and I get a 500...

    JavaScript validation on name field not working


    javascript,forms,validation
    I am trying to make my form validation work but I somehow can't make my name field to validate properly. When I write names in the field it will say that I need to write a proper name. What am I doing wrong? HTML: http://pastebin.com/EfNSkQkS JavaScript: http://pastebin.com/c6iUCYvr

    Laravel 5 form request validation returning forbidden error


    php,validation,laravel,laravel-4,laravel-5
    I am trying to use Laravel 5.1's form request validation, to authorize if the request is from the owner. The validation is used when the user is trying to update part of the table clinics through the show.blade.php. My set up so far: routes.php: Route::post('clinic/{id}', array('as' => 'postUpdateAddress', 'uses' =>...

    Validation on Radio Buttons


    c#,wpf,validation,data-binding,radio-button
    I'm not really sure how to word this, so here goes. I've got some radio buttons on a form in my WPF application which get validated. They're basically a required field for this form. When I start to fill in the form, both radio buttons are marked with a red...

    Form submit portlet with Spring MVC


    java,jsp,spring-mvc,liferay,portlet
    I'm trying to achieve a Liferay portlet of submit form using spring MVC. The model: package com.model; public class Person { String firstName; String middleName; public String getFirstName() { return this.firstName; } public String getMiddleName() { return this.middleName; } public void setFirstName(String firstName) { this.firstName=firstName; } public void setMiddleName(String middleName)...

    Validate row with inputs in a table that has been built dynamically in AngularJS


    javascript,html,angularjs,validation,angularjs-ng-repeat
    I've been struggling on the solution to the following problem. I have a table in which every row is build dynamically by ngRepeat. Every row has four columns and in every column there is an input element. My question is - how can I validate these four input fields and...

    how to multiply two column names using codeigniter validation rule


    php,codeigniter,validation
    I have three columns.The product of two columns get into third column name income_amount using codeigniter validation rule.the first column is crop_quantity and the second is per_rate controller $this->form_validation->set_rules('crop_quantity', 'Crop Quantity', 'required|numeric'); $this->form_validation->set_rules('per_rate', 'Per Rate', 'required|numeric|callback_get_product'); $this->form_validation->set_rules('income_amount', 'Income Amount', 'required|numeric');...

    How to validate in database for uniqueness?


    ruby-on-rails,validation,ruby-on-rails-4
    I am using Rails 4.2 with Ruby 2.1.5. Here is my API table: create_table "apis", force: :cascade do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" t.string "status" t.string "coname" end How do I validate that a user cannot create an API with the same name and same status twice? For...

    Validation of a form before submission


    php,validation,symfony2,form-submit
    Using Symfony, version 2.3 and more recent, I want the user to click on a link to go to the edition page of an already existing entity and that the form which is displayed to be already validated, with each error associated to its corresponding field, i.e. I want the...

    jQuery validate equalTo


    javascript,jquery,validation
    I would like to use jQuery validate() plugin using the equalTo to validate a signature field, basically the signature field must match the first name and last name field, is this possible using the validate() plugin? http://jqueryvalidation.org/equalTo-method/ shows me how to check if it is equal to another input, but...

    C# Validate DataSet filled with DGV data as XML


    c#,xml,validation,datagridview,xsd
    I want to make a "Save as" button which will validate data from dataGridView with .xsd XML schema before saving it as an XML file. The idea was to save DataTable filled with DGV data as an XML, validate it with .xsd and delete it if the file is valid...

    mvc 4 custom format validator does not show error and allows the form to submit


    asp.net-mvc,validation,asp.net-mvc-4
    I have the following validator for a MVC 4 view public class IpFormatValidator: ValidationAttribute { protected override ValidationResult IsValid(object value, ValidationContext validationContext) { ValidationResult resp; if (value != null) { string ip ; IPAddress noUsed ; ip = value.ToString(); if(IPAddress.TryParse(ip, out noUsed)) { resp = ValidationResult.Success; } else { resp...

    Regualr expression to check ip address with short mask


    php,validation,ip-address
    I want to validate an IP address with mask, like this: 192.168.32.4/24 but I only found how to validate an IP without the mask: 192.168.32.4 This is my code: $target = "192.168.34.12"; if (preg_match("/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/", $target)) { echo "correct"; } else { echo "incorrect"; } Thanks in advance. [Solved] $target =...

    Symfony2 form builder without class check if multiple fields are empty


    validation,symfony2,constraints,formbuilder
    I am using form builder without class and have two fields with each having constraints : $form = $this->createFormBuilder() ->add('name', 'text', array( 'required'=>false, 'constraints'=> new Length(array('min'=>3) )) ->add('dob', 'date', array( 'required'=>false, 'constraints'=> new Date() )) ->getForm() ->handleRequest($request); This works great but I want to check if both fields are emtpy,...

    Validation of text fields and contact no text field


    java,swing,validation,textfield
    I have a JFrame consisting of some text fields (10) and a TextArea. I want to validate all the text fields and see if they are not empty and also check if a 10 digit contact no is entered in one of the text field. After checking the text fields,...

    angular validation not working on select


    javascript,angularjs,validation
    its a simple form a drop down and a save button. On page load Select should be ng-invalid because it is required and nothing is selected but form and select both are ng-valid and save function is called. and once i select any thing and un select it. then it...

    How to avoid Hibernate Validator ConstraintDeclarationException?


    java,spring,hibernate,validation,hibernate-validator
    I have my WebService based on Spring 4, and I am using Hibernate Validator (beyond MethodValidationPostProcessor). My problem is that I have my ClientService interface, and its implementation. So I put Bean Validation constraints on the implementation and it forces me to put that constraints on the interface (throwing ConstraintDeclarationException)...