Created
May 20, 2014 15:31
-
-
Save DisaTemp/bf3538315426907f923d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Virtual Keyboard Basic Demo</title> | |
<!-- demo --> | |
<link href="demo/demo.css" rel="stylesheet"> | |
<!-- jQuery & jQuery UI + theme (required) --> | |
<link href="http://code.jquery.com/ui/1.9.0/themes/ui-darkness/jquery-ui.css" rel="stylesheet"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.js"></script> | |
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.min.js"></script> | |
<!-- keyboard widget css & script (required) --> | |
<link href="css/keyboard.css" rel="stylesheet"> | |
<script src="js/jquery.keyboard.js"></script> | |
<!-- keyboard extensions (optional) --> | |
<script src="js/jquery.mousewheel.js"></script> | |
<!-- initialize keyboard (required) --> | |
<script> | |
function numPad(fieldName, unit){ | |
var k = $('#' + fieldName); | |
k.keyboard({ | |
layout: 'num', | |
hidden : function(e, keyboard, el) { | |
// add "px" suffix | |
$(el).val(function(indx, val){ | |
var beforeSpace = val.replace(/[A-Za-z$-]/g, "").split(" "); | |
if (isAlphanumeric(beforeSpace[0])){ | |
return val; | |
} | |
else{ | |
return beforeSpace[0] + ' ' + unit; | |
} | |
}); | |
}, | |
visible: function(e, keyboard, el) { | |
keyboard.$preview[0].select(); | |
} | |
}) | |
function isAlphanumeric(str) { | |
return /^[0-9a-zA-Z]+$/.test(str); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<!-- keyboard input --> | |
<input id="keyboard" name="keyboard" type="text" value="102.27 PSI" onclick="numPad('keyboard', 'PSI');"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment