Validation not working in formit

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

  [[!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>

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.

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

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

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

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

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”.