Input Field validations: Do they validate?

Topics: General
Sep 28, 2012 at 12:32 AM

I am not getting any Input Fields to validate input when I specify it is text with a regex string, Email, or Tel (I have not tried Url for lack of current need). It does not seem to matter what is entered in the fields, upon creating an item that contains these fields they all validate. I can put partial phone numbers or just alpha characters in a Tel field, incomplete email addresses in an Email field, and anything that would not normally pass a regex check in the Text field. The only thing they successfully check on is that there is values in the fields that are set to required.

Am I missing something? or is this a known issue?

Coordinator
Sep 28, 2012 at 5:44 AM

File a bug.

Developer
Sep 28, 2012 at 8:45 AM

Currently, the Input Field only uses its settings to generate an Html 5 input with a specific type and some attributes.

See examples here :

http://www.w3schools.com/html5/tag_input.asp

These Html 5 input type and attributes are not supported the same way in all browsers.

I guess you use IE. You should give a try of how it is managed with Chrome, Firefox or Opera.

For example, try your input type=email or type=tel with a regular expression and you should see the warning submitting the form.

The regexp is used to generate the pattern attribute :

http://www.w3schools.com/html5/att_input_pattern.asp

What you need to understand is that this is only dependent on the browser for the moment (kind of client side, but not exactly).

 

The input field needs may be some enhancements to have better client side and server side validation (and add possibility to specify the error message).

As Bertrand said : File a bug.

Sep 28, 2012 at 6:28 PM

Thank you. That does explain the issue and I can see in Chrome that is is working.

Yes, I am using IE as do most people at this time. I could see that if it did not work in Opera then I would not be concerned but since this fails to work in the most commonly used browser it causes some issues. :)

Coordinator
Sep 30, 2012 at 8:26 AM

As a matter of facts, most people *DON'T* use IE nowadays. Those fields are progressive improvements. If the browser doesn't support the new fields, they simply behave like ordinary text fields. Validation should be done server-side as well so it shouldn't matter.

Developer
Sep 30, 2012 at 10:04 AM

The issue has been created : http://orchard.codeplex.com/workitem/19072

Sebastien replied it was by design to have client-side validation.

At least, I think we should add progressive enhancement for client-side to support the browsers that don't implement all the attributes HTML 5 input types.

A simple first step would be to make a side-by-side Modernizr module to be able to activate some fallbacks : https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills 

I will try to make a sample. To do this, I will have to find a script that allow to handle easily regular expressions validation in jquery)

Sep 30, 2012 at 5:43 PM

Yes, I spoke incorrectly. What I meant was it is still the most popularly used browser, or was until May according to StatCounter. It seems that this functionality, as wonderful as it is to be a standard, should be considered a proof of concept or provide an IE alternative solution (such as: http://www.matiasmancini.com.ar/jquery-plugin-ajax-form-validation-html5.html) until the majority of IE users are running version 10. At the very least, the help description on the Input Field type should warn users that the validations do not work in IE 9 or less so that people are not frustrated in trying to figure out why their users input is coming through with no checks.

I also agree that validations should also be handled server side, but these fields do not do that nor do they even describe how the validation is performed.

Thanks for the help in figuring this one out. I'll try getting a jQuery plugin to work for my needs at the moment, then build a custom module with server-side validations to better serve my puposes later.