JavaScript
Article
By Sam Deering

Added HTML5 Validation to the on-screen keyboard

By Sam Deering

A while ago I uploaded a demo (enhancements of the jQuery on-screen keyboard). Since I have added support for HTML5 form validation. In the write function it basically checks the inputs for HTML5 validation rules to determine output write. This is the gist of it:

See Keyboard Demo See Keyboard Demo

write: function(m) {

--ADVERTISEMENT--

var $el = jsKeyboard.currentElement,
val = $el.val(),
charStr = String.fromCharCode(m),
pos = jsKeyboard.currentElementCursorPosition,
output = [val.slice(0, pos), charStr, val.slice(pos)].join(”),
doWrite = true;

//max length – html5: maxlength=”x”
if ($el.attr(‘maxlength’))
{
doWrite = (output.length

Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account