Monthly Archives: August 2014

Using Validation and Vibration API in HTML5

HTML5 provides bevy of features which enable developers to build some really interesting applications. In this example I will build a small HTML5 based validation which will vibrate the mobile device in case of invalid input.

Validation API

Validation in HTML5 is as simple as adding an attribute. Just add the required attribute and you are good to go.

In the above code snippet the text field is required and browser supporting this attribute will not let you submit the form if the field value is empty.

Now we need to check if the user has entered valid value in the field or not. It he hasn’t then we vibrate the mobile device. To check it in JavaScript use the statement input.validity.valid. This returns true in case valid value is entered in the field else returns false. In case its invalid you can then vibrate the mobile device using Vibration API.

Vibration API

This article describes Vibration API and how easy it is to implement.

First you need check if the device supports Vibration API Continue reading

Share:


Fatal error: Call to undefined function bccl_full_html_license() in /var/sites/p/pipalia.co.uk/public_html/wp-content/themes/pipalia-ltd/archive.php on line 57