# \[Feature-1646, 3837\] Client-side (browser) form validation in Perspective

**URL:** <https://forum.inductiveautomation.com/t/feature-1646-3837-client-side-browser-form-validation-in-perspective/48789>\
**Category:** General Discussion\
**Tags:** perspective, ignition81\
**Created:** [July 13, 2021, 5:43pm UTC](https://forum.inductiveautomation.com/t/feature-1646-3837-client-side-browser-form-validation-in-perspective/48789 "2021-07-13T17:43:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [July 13, 2021, 5:43pm UTC](https://forum.inductiveautomation.com/t/feature-1646-3837-client-side-browser-form-validation-in-perspective/48789/1 "2021-07-13T17:43:05Z")

</div>

# Client-side Input Validation in Perspective

With Perspective, we are able to create beautiful user interfaces for data collection, reporting, and even controlling machines. I often find myself creating forms for data collection and I was wondering if / when we will be able to use standard HTML input validation techniques for forms (and to create the "forms" themselves).

## Here are a few examples of what I mean:

### 1. Creating HTML-style forms

This allows for better organization when grouping related inputs together. Also, there is an `action` attribute which specifies where the form data is to be sent (I don't know how this would work with Perspective - it isn't that important).

```html
<form action="/my-endpoint">
    ...
</form>

```

In my experience, it would be very useful if we were able to create forms because of the next few points.

### 2. HTML `required` attribute

Having a `Form` component would allow us to do something like this:

```html
<form action="">
    <label for="name_input">First Name:</label>
    <input type="text" id="name_input" name="name" required>

    <button type="submit">Submit</button>
</form>

```

renders this beautiful form:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/d/ddd44f8ea9872bd90e6e151858204a31c5fb387d.png)  
The important thing here is what happens when we try to submit the form with the input empty (Chrome v91.0.4472.124):

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/e/2e97ed0e10228a9aa91c716ff1380150147f19f7.png)  
This alert is added by the browser automatically (might look different in Safari/Firefox/Edge, etc) and doesn't allow the user to submit the form until those fields contain valid inputs.

### 3. Email and other `input` types

Right now, many different HTML `input`s are their own Perspective component. This makes sense, since a radio button and a password input are vastly different and it makes it easier on the developer when styling and customizing components. However, that does mean some well-supported input types like `email` and `tel` will need to be entered into a Text Field component and validated through scripting. The browser is capable of providing that functionality, it would be nice if we could harness it.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2dd49b9714572c62276ede6f995fdb4e350d7516.png)

### 4. And so on...

## Conclusion

I understand that "form validation" could be added through scripting (server-side). However, it makes sense for me, as a happy consumer of the Ignition platform, for some sort of validation to be built-in at the client level. Not a huge priority, but definitely a nice-to-have.

---

<div class="post-metadata">

**Author:** ![weixionglichina](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/weixionglichina/32/10650_2.png) [@weixionglichina](https://forum.inductiveautomation.com/u/weixionglichina)\
**Post date:** [August 6, 2021, 3:34am UTC](https://forum.inductiveautomation.com/t/feature-1646-3837-client-side-browser-form-validation-in-perspective/48789/2 "2021-08-06T03:34:35Z")

</div>

Up

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 6, 2021, 4:15pm UTC](https://forum.inductiveautomation.com/t/feature-1646-3837-client-side-browser-form-validation-in-perspective/48789/3 "2021-08-06T16:15:55Z")

</div>

Specifying the `type` of input elements is actually something that’s already on our backlog.  
I’m not sure about the form handling - it’s a good idea, but may not actually work that well with Perspective - despite the URL navigation, really the entire Perspective session is a single page; what would you expect to happen on form submission?  
I guess theoretically it could be a container type with a specific scripting hook that fires on form submission… I filed a ticket.

---

<div class="post-metadata">

**Author:** ![weixionglichina](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/weixionglichina/32/10650_2.png) [@weixionglichina](https://forum.inductiveautomation.com/u/weixionglichina)\
**Post date:** [August 9, 2021, 1:14am UTC](https://forum.inductiveautomation.com/t/feature-1646-3837-client-side-browser-form-validation-in-perspective/48789/4 "2021-08-09T01:14:13Z")

</div>

Perfect! That’s gonna be super good!  
Input elements validation is quite OK to me, I’d like to do submission manually and then decide where to go.

---

<div class="post-metadata">

**Author:** ![Corne\_de\_Jonge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/corne_de_jonge/32/46823_2.png) [@Corne\_de\_Jonge](https://forum.inductiveautomation.com/u/Corne_de_Jonge)\
**Post date:** [April 7, 2023, 6:56am UTC](https://forum.inductiveautomation.com/t/feature-1646-3837-client-side-browser-form-validation-in-perspective/48789/5 "2023-04-07T06:56:26Z")

</div>

Any developments yet for this feature request?

It would be a real nice-to-have feature, so we can let the customer know that the input of a field is incorrect before they even press a 'confirm/submit' button. And this way it would be easier to see for the customer of which fields the input is incorrect.

Of course it would be more of an add-on, because I feel that validating via scripting would always be the most safe way to go.
