Snippets Javascript
Filtrage de touches sur une Form Input
function set_form_alias_keypress_listener () { var myAliasInputElement = document.getElementById('useralias'); myAliasInputElement.addEventListener('keypress', function(theEvent) { var myEvent = theEvent ? theEvent : event; var myKeyCode = myEvent.which || myEvent.keyCode; var myKeyOK = false; myKeyOK |= (myKeyCode >= 97) && (myKeyCode <= 122); // a-z myKeyOK |= (myKeyCode >= 48) && (myKeyCode <= 57); // 0-9 myKeyOK |= (myKeyCode == 8); // backspace if (!myKeyOK) { myEvent.preventDefault(); }; }); };
GMT DateTime
var now = new Date(); var now_sqlgmdatetime = now.getUTCFullYear() + "/" + ("0" + (now.getUTCMonth()+1)).slice(-2) + "/" + ("0" + now.getUTCDate()).slice(-2) + " " + ("0" + now.getUTCHours()).slice(-2) + ":" + ("0" + now.getUTCMinutes()).slice(-2) + ":" + ("0" + now.getUTCSeconds()).slice(-2); var now_gmdatetime = new Date(now_sqlgmdatetime);