The HTML5 Input Types Addon provides native Couch support for the HTML5 input types, including:
Once the addon is activated, you can use these types just like you would any of the standard input types.
This addon also provides support for the HTML5 "required" attribute - but only for these input types - by including the "required" attribute in the rendered tag for browser-based validation.
The addon not only renders the input tags, but also adds automatic server-side validation to back up native browser validation. Couch will generate the same errors that you would expect from browser validation. Error messages can be modified in the language files for customization and localization.
Type 'email' uses Couch's built in email validation, so customization would be done with a validator_msg parameter.
Since automatic validation can sometimes interfere with what you want to accomplish, it can be disabled by setting the parameter validate='0' on any of these input types. The parameter validate='0' will turn off automatic validation for the tag but won't affect any other Couch validation that is present. For example, the following line won't validate the email address, but the field will still be required:
Please be aware that PHP is only cabable of understanding numbers up to 12 digits, so server-side validation will fail with very large numbers or numbers with too many decimal places. But for most ordinary uses you are unlikely to run up against this limitation.
Thanks to @KK for support and guidance on this project!
Installing the Addon:
Download and unzip the file. Place the unzipped folder in your couch/addons/ folder. Register the addon by adding a line of code to couch/addons/kfunctions.php.
https://github.com/fallingsprings/couch ... nput-types
- type="email"
type="url"
type="tel"
type="search"
type="color"
type="number"
type="range"
type="date"
type="time"
Once the addon is activated, you can use these types just like you would any of the standard input types.
This addon also provides support for the HTML5 "required" attribute - but only for these input types - by including the "required" attribute in the rendered tag for browser-based validation.
The addon not only renders the input tags, but also adds automatic server-side validation to back up native browser validation. Couch will generate the same errors that you would expect from browser validation. Error messages can be modified in the language files for customization and localization.
Type 'email' uses Couch's built in email validation, so customization would be done with a validator_msg parameter.
- Code: Select all
<cms:input type="email" name="email" required='1' validator_msg='required=Please enter your email.|email=Not a valid email. Please check for mistakes.' />
Since automatic validation can sometimes interfere with what you want to accomplish, it can be disabled by setting the parameter validate='0' on any of these input types. The parameter validate='0' will turn off automatic validation for the tag but won't affect any other Couch validation that is present. For example, the following line won't validate the email address, but the field will still be required:
- Code: Select all
<cms:input type='email' name='email' validate='0' required='1' />
Please be aware that PHP is only cabable of understanding numbers up to 12 digits, so server-side validation will fail with very large numbers or numbers with too many decimal places. But for most ordinary uses you are unlikely to run up against this limitation.
Thanks to @KK for support and guidance on this project!
Installing the Addon:
Download and unzip the file. Place the unzipped folder in your couch/addons/ folder. Register the addon by adding a line of code to couch/addons/kfunctions.php.
- Code: Select all
require_once( K_COUCH_DIR.'addons/html5-input-types/html5-input-types.php' );
https://github.com/fallingsprings/couch ... nput-types