# Validation property from other input field?

**URL:** <https://discourse.nodered.org/t/validation-property-from-other-input-field/76518>\
**Category:** Developing Nodes\
**Created:** [13 March 2023 16:05 UTC](https://discourse.nodered.org/t/validation-property-from-other-input-field/76518 "2023-03-13T16:05:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![znetsixe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/znetsixe/32/72588_2.png) [@znetsixe](https://discourse.nodered.org/u/znetsixe)\
**Post date:** [13 March 2023 16:05 UTC](https://discourse.nodered.org/t/validation-property-from-other-input-field/76518/1 "2023-03-13T16:05:16Z")

</div>

I know there are other threads on this topics but cant seem to find my precise question so fast so here it goes :

I want to use the validation function to use 2 of the users input and check if minimum is bigger than maximum input.  
my code :

```auto
i_min:{value:0, 
                required:true,
                validate:function(v) {
                    let result = false;
                    let i_max = $("#node-input-i_max");
                    if(v<i_max){result = true;}
                   
                    return result;
                }
            },
            i_max:{value:0}, 

```

If I fill in a number for i\_max manually in the code for example 5 it does the check like I expect it. So this part $("#node-input-i\_max") doesnt seem to work. Could somebody direct me to the right syntax to get the input for my i\_max value assuming the name is " node-input-i\_max "

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [13 March 2023 17:08 UTC](https://discourse.nodered.org/t/validation-property-from-other-input-field/76518/2 "2023-03-13T17:08:18Z")

</div>

If you have not already seen it, you should look at the `custom` property validator in the example [here](https://nodered.org/docs/creating-nodes/properties#property-validation).

---

<div class="post-metadata">

**Author:** ![znetsixe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/znetsixe/32/72588_2.png) [@znetsixe](https://discourse.nodered.org/u/znetsixe)\
**Post date:** [13 March 2023 17:14 UTC](https://discourse.nodered.org/t/validation-property-from-other-input-field/76518/3 "2023-03-13T17:14:17Z")

</div>

Ive seen it and tried various things but cant make up what the syntax says...

$("node-input-i\_max").val() for example doesnt work either which is something I thought would hold the value of the input for i\_max which the user entered?

Which is maybe the better question here for me. Could someone break down the syntax wrote in the example for me ? Then I could see where my error lies :

```auto
 custom: { value:"", validate:function(v) {
      var minimumLength=$("#node-input-minimumLength").length?$("#node-input-minimumLength").val():this.minimumLength;
      return v.length > minimumLength
   } }

```

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [13 March 2023 17:34 UTC](https://discourse.nodered.org/t/validation-property-from-other-input-field/76518/4 "2023-03-13T17:34:50Z")

</div>

> [@znetsixe](#):
>
> which is something I thought would hold the value of the input

I thought so too, but I'm no jQuery expert. Others might be able to help. You could try logging these variables to the console to see what they hold.

---

<div class="post-metadata">

**Author:** ![znetsixe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/znetsixe/32/72588_2.png) [@znetsixe](https://discourse.nodered.org/u/znetsixe)\
**Post date:** [13 March 2023 17:58 UTC](https://discourse.nodered.org/t/validation-property-from-other-input-field/76518/5 "2023-03-13T17:58:26Z")

</div>

ok so it dit work as I expected it... it was the value of the input...  
it translated it to text in stead of a number... even though the input explicitely is put as number...

so this fixed it :

```auto
i_min:{value:0, 
                required:true,
                validate:function(v) {
                    let result = false;
                    let i_max = $("#node-input-i_max").val();
                    if( parseFloat(v) < parseFloat(i_max) ){result = true;}
                    //alert(v);
                    return result;
                }
            },
            i_max:{value:0,required:true}, 

```

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [13 March 2023 20:36 UTC](https://discourse.nodered.org/t/validation-property-from-other-input-field/76518/6 "2023-03-13T20:36:56Z")

</div>

It's an html thing. The browser has no way to know what you want to do with the input, and at bottom it can only handle text. Converting input to a JavaScript type is up to you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 March 2023 20:37 UTC](https://discourse.nodered.org/t/validation-property-from-other-input-field/76518/7 "2023-03-27T20:37:04Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
