How to declare that an HTML input is required

#1

Hi,
I want to declare an input (which is part of an EditableList) as required
I have tried that

$( "<input/>", { class: "node-input-text-value-en" ,
                 type : "text",
                 style: "margin-left: 15px; width: 70%;",
                 required
               }
  )

But it doesn't work ... can you help ? Thx

0 Likes

#2

Hi @Lionel - when sharing code, please use ``` around your code rather than blockquoting which doesn't do anything to maintain the code formatting.

"required" is not a flag you set on the html input element - you set it against the properties listed in the node's defaults object. https://nodered.org/docs/creating-nodes/properties

0 Likes

#3

BUT, the concerned input element is part of an EditableList, so it is not declared in the default objects, only the EditableList is declared in defaults

0 Likes

#4

In which case you'll have to build in your own logic to check if the field has a valid value or not. There's no built-in way of doing that.

0 Likes

#5

I have added a "border" property in the input style, in case of bad entry

style: "margin-left: 15px; width: 70%; border: solid 1px #FF0000;"

And it seems, it is not supported, there is no effect.
Can you tell me where I can find the supported HTML options for the input ?

0 Likes