Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function inputCheck()
- {
- var check = document.forms["drinkList"]["quant1"].value
- if (isNaN(check))
- {
- window.alert("Input numbers only");
- return false;
- }
- }
- <input onchange="inputCheck(this)">
- function inputCheck(elem){
- var check = elem.value;
- if (isNaN(check))
- {
- window.alert("Input numbers only");
- return false;
- }
- }
- var names = ['quant2', 'quant3', 'quant4', 'quant5', 'whip', 'cream', 'sugar', 'chocolate', 'caramel2'];
- document.body.addEventListener('keyup', function (e) {
- // skip event if it was NOT triggered on a matching element
- if (names.indexOf(e.target.name) === -1) { return; }
- // code to process event...
- });
- $("#drinkList .nonNumberTextbox").each(function(index, node) {
- if (isNaN(node.value)) {
- window.alert("Input numbers only");
- return false;
- }
- });
- if (check.trim() === '' || isNaN(+check)) {
- if (isNaN(parseInt(check, 10))) { // if only integers are allowed
- }
- if (isNaN(parseFloat(check))) { // if integers and decimals are allowed
- }
- if(!/^d+$/.test(check)) { // if the number needs to be an integer
- }
- if(!/^d+(?:.d*)?$/.test(check)) { // if the number can be an integer or a decimal
- }
- var textboxes = ['quant2', 'quant3', 'quant4', 'quant5', 'whip', 'cream', 'sugar', 'chocolate', 'caramel2'];
- for (var i = 0; i < textboxes.length; i++ ){
- var check = document.forms["drinkList"][textboxes[i]].value;
- if (isNaN(check)){
- window.alert("Input numbers only");
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement