# How to validate values in mautic forms (Components - Forms)?

**URL:** <https://forum.mautic.org/t/how-to-validate-values-in-mautic-forms-components-forms/25523>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [September 27, 2022, 4:58pm UTC](https://forum.mautic.org/t/how-to-validate-values-in-mautic-forms-components-forms/25523 "2022-09-27T16:58:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![poetry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/poetry/32/1272_2.png) [@poetry](https://forum.mautic.org/u/poetry)\
**Post date:** [September 27, 2022, 4:58pm UTC](https://forum.mautic.org/t/how-to-validate-values-in-mautic-forms-components-forms/25523/1 "2022-09-27T16:58:05Z")

</div>

**Your software**  
_My PHP version is_ : 8.0.23  
_My MariaDB version is_ : 10.6.10-MariaDB-1:10.6.10+maria~deb11

**Your question**  
_My question is_ :

I am integrating forms into website so people can contact us. I would like to validate the values that people can send.

For example I am using form where a person can enter a domain name.  
I would like to validate that the domain name is in the right format for example [example.com](http://example.com) is a valid domain name examplecom is not a valid domain name.

I also have one form where a person enters a number as a value. I would like to limit the values to only positive number up to for example 1000. Invalid value would be -10 valid value would be 0, 10, 1000.

 ![domain-name](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/e/e12dbd1a02ef1ede638db730605fac3c01ddd845.png)  
 ![domain-name1](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/6/6489f041880784b7d20fe5385517c3f3cdbbf176.png)  
 ![domain-name2](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/8/81cf10fa1682dfb368807a27e43494e8903d3ebb.png)  
 ![domain-name3](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/4/4d1c68b15b26863d92224623e6aaf5b749510764.png)

Anyone has any idea how to achieve this? I am running the latest Mautic Community 4.4.3  
Thank you.

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [September 27, 2022, 5:04pm UTC](https://forum.mautic.org/t/how-to-validate-values-in-mautic-forms-components-forms/25523/2 "2022-09-27T17:04:03Z")

</div>

For email if you use email field browser validation will validate the value for you \<input type=“email” …/\>

Same goes for number, select the number type field, turn on field validation and add min max attributes to field.

Unless I misunderstood something that should be all.

---

<div class="post-metadata">

**Author:** ![poetry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/poetry/32/1272_2.png) [@poetry](https://forum.mautic.org/u/poetry)\
**Post date:** [September 27, 2022, 6:03pm UTC](https://forum.mautic.org/t/how-to-validate-values-in-mautic-forms-components-forms/25523/3 "2022-09-27T18:03:28Z")

</div>

Thanks for the response. I have a hard time finding “field validation”. Can you post a screenshot where to do this or it’s just custom code?  
Validation is only required nothing more. Maybe I am missing something.

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [September 27, 2022, 6:28pm UTC](https://forum.mautic.org/t/how-to-validate-values-in-mautic-forms-components-forms/25523/4 "2022-09-27T18:28:55Z")

</div>

In the screenshot above you have Validation tab, click on it, and turn on validation. On attributes tab, you can set min, max html attributes.

---

<div class="post-metadata">

**Author:** ![poetry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/poetry/32/1272_2.png) [@poetry](https://forum.mautic.org/u/poetry)\
**Post date:** [September 27, 2022, 6:41pm UTC](https://forum.mautic.org/t/how-to-validate-values-in-mautic-forms-components-forms/25523/5 "2022-09-27T18:41:19Z")

</div>

I see here are the help if I hover over the labels

 ![values](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/5/56edc8622e34dd9308ac0854d60e36fb0d2fed95.png)

Do you have an example how can I set the value so it will only accept positive number up to 1000 including 0?

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [September 27, 2022, 6:45pm UTC](https://forum.mautic.org/t/how-to-validate-values-in-mautic-forms-components-forms/25523/6 "2022-09-27T18:45:34Z")

</div>

In Input attributes add the following:

`min="0" max="1000"`

I think this should cover your requirement.

---

<div class="post-metadata">

**Author:** ![poetry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/poetry/32/1272_2.png) [@poetry](https://forum.mautic.org/u/poetry)\
**Post date:** [September 27, 2022, 6:57pm UTC](https://forum.mautic.org/t/how-to-validate-values-in-mautic-forms-components-forms/25523/7 "2022-09-27T18:57:13Z")

</div>

This kind of works. I have a problem now because I have multiple “Page break” and it will let you go next page without any warning and then you won’t be able to submit but you won’t know why. Is there any way to show validation messages and not let the page break to the next page when the values are not valid?

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [September 27, 2022, 7:08pm UTC](https://forum.mautic.org/t/how-to-validate-values-in-mautic-forms-components-forms/25523/8 "2022-09-27T19:08:43Z")

</div>

Browser validation happens after you hit submit, so if you want to customize that behavior you would need to validate with custom JS.
