Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Granit UI Fileupload has no required field

Avatar

Avatar
Validate 1
Level 2
Reini-
Level 2

Likes

4 likes

Total Posts

21 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
Reini-
Level 2

Likes

4 likes

Total Posts

21 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile
Reini-
Level 2

25-07-2016

Hi,

I can't find the property "required" in the granite ui filepuload field (https://docs.adobe.com/docs/en/aem/6-1/ref/granite-ui/api/jcr_root/libs/granite/ui/components/founda...). A lot of other fields (e.g. textfield) has this property. Why is it missing in fileupload field and is there a way to solve this requirement?

regards

Reini

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,162 likes

Total Posts

6,273 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,162 likes

Total Posts

6,273 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

26-07-2016

Hi 

The workaround for this is to write own custom validator, it is very easy.

Please have a look at this :-

Registering custom validators is done by calling the jQuery based $.validator.register method. The register method takes a single JavaScript object literal argument. The parameter looks for four properties: selector, validate, show and clear, of which only selector is required.

$.validator.register({
  selector: '.field-phonenumber',
  validate: function(el) {
    var field,
        value;

    field = el.closest(".coral-Form-field");
    value = el.val();

    if (!/^\d{3}-\d{3}-\d{4}$/.test(value)) {
      return Granite.I18n.get('The field must be a phone number in the format of "xxx-xxx-xxxx"');
    }
  },
  show: function (el, message) {

<code>

},
  clear: function (el) {
    var field = el.closest(".coral-Form-field");

   <code>

  }
});

 

Please have a look at this community article written by Nate Yolles :- http://www.nateyolles.com/blog/2016/02/aem-touch-ui-custom-validation

 

I hope this will help you.

Thanks and Regards

Kautuk Sahni

Answers (0)