Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
18 posts Page 1 of 2
The HTML5 Input Types Addon provides native Couch support for the HTML5 input types, including:

    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

Attachments

Hello tim,

Thanks for this addon, it amazing! Really simple to use and helps me a lot!

All the best,

RafaelNC
Thanks @tim!
Thanks for your encouragement, RafaelNC and cheesypoof. :)

I've updated the addon to include language files for localization and customization of error messages. If anyone can add a language file, please share it here and we'll include it in the addon for the benefit of the rest of the community. There are only a few error messages, so it won't take much effort to create a translation.

Thanks,
Tim
Here comes russian.
Have you got any more serious task? 8-)

Attachments

Cпасибо, @trendoman. :D
This is the HINDI translation for the error messages to be displayed for the HTML5 support

Attachments

Image
where innovation meets technology
धन्यवाद, @genxcoders! :D
इसका उल्लेख न करें @tim!
Image
where innovation meets technology
had to add static to handle_params() methods within a few classes to get this to work with Couch 2.0
18 posts Page 1 of 2

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 3 guests