# Validation not working in formit

**URL:** <https://community.modx.com/t/validation-not-working-in-formit/6198>\
**Category:** Extras\
**Tags:** formit\
**Created:** [December 22, 2022, 10:01am UTC](https://community.modx.com/t/validation-not-working-in-formit/6198 "2022-12-22T10:01:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dimitris1981](https://community.modx.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dimitris1981](https://community.modx.com/u/dimitris1981)\
**Post date:** [December 22, 2022, 10:01am UTC](https://community.modx.com/t/validation-not-working-in-formit/6198/1 "2022-12-22T10:01:41Z")

</div>

Hello,  
I copied paste a formit example from documention in order to test the validation. However no error message appears and the form is submitted even when the “name” field is empty…  
Any help would be greatly appreciated. The formit version is the 4.2.7-pl

```auto
  [[!FormIt?
                               &hooks=`email,redirect`
                               &emailTpl=`MyEmailTest`
                               &emailTo=`test@hotmail.com`
                               &emailFrom=`test@example.gr`
                               &validate=`name:required`
                               &redirectTo=`18`
                            ]]

<h2>Contact Form</h2>

[[!+fi.validation_error_message:notempty=`<p>[[!+fi.validation_error_message]]</p>`]]

<form action="[[~[[*id]]]]" method="post" class="form">

    <label for="name">
        Name:
        <span class="error">[[!+fi.error.name]]</span>
    </label>
    <input type="text" name="name" id="name" value="[[!+fi.name]]" />
    <div class="form-buttons">
        <input type="submit" value="Send Contact Inquiry" />
    </div>
</form>

```

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [December 22, 2022, 10:52am UTC](https://community.modx.com/t/validation-not-working-in-formit/6198/2 "2022-12-22T10:52:52Z")

</div>

I tested this with the same _FormIt_ version (on MODX 2.8.4, PHP 7.4), but I can’t reproduce the problem.  
The validation works as expected.

---

<div class="post-metadata">

**Author:** ![dimitris1981](https://community.modx.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dimitris1981](https://community.modx.com/u/dimitris1981)\
**Post date:** [December 23, 2022, 6:48am UTC](https://community.modx.com/t/validation-not-working-in-formit/6198/3 "2022-12-23T06:48:42Z")

</div>

Is it possible to be a server issue or something outside modx? The form is submitted without any validation…

---

<div class="post-metadata">

**Author:** ![dimitris1981](https://community.modx.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dimitris1981](https://community.modx.com/u/dimitris1981)\
**Post date:** [January 3, 2023, 5:28am UTC](https://community.modx.com/t/validation-not-working-in-formit/6198/4 "2023-01-03T05:28:06Z")

</div>

Ok found the solution… I had two forms in the same page. I removed it and it works as expected.

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [January 3, 2023, 4:17pm UTC](https://community.modx.com/t/validation-not-working-in-formit/6198/5 "2023-01-03T16:17:09Z")

</div>

For multiple forms on the page, you can add the property `&submitVar`, so that _FormIt_ checks, if the correct form was sent.

```auto
[[!FormIt? 
   ... 
   &submitVar=`mySubmit` 
]] 
<form id="myform" action="[[~[[*id]]]]" method="post">    
   ... 
   <input type="submit" name="mySubmit" value="Send"> 
</form>

```

---

<div class="post-metadata">

**Author:** ![system](https://community.modx.com/user_avatar/community.modx.com/system/32/2_2.png) [@system](https://community.modx.com/u/system)\
**Post date:** [January 5, 2023, 4:17pm UTC](https://community.modx.com/t/validation-not-working-in-formit/6198/6 "2023-01-05T16:17:55Z")

</div>

Closed on January 5, 2023, 4:17pm UTC

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.
