From 784242c7d863f1c84dce8d54248a0f98135deafb Mon Sep 17 00:00:00 2001 From: David Steinbrunner Date: Tue, 29 May 2012 20:43:32 -0300 Subject: [PATCH] Patch I have used for awhile: - Support password fields - Send the element in question to the callback so that one handler can be used for multiple fields and the handler can use info from the element, such as id, to determine what needs done. --- src/typewatch.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/typewatch.js b/src/typewatch.js index fcb529b..045b1dc 100644 --- a/src/typewatch.js +++ b/src/typewatch.js @@ -32,13 +32,13 @@ if ((elTxt.length >= options.captureLength && elTxt.toUpperCase() != timer.text) || (override && elTxt.length >= options.captureLength)) { timer.text = elTxt.toUpperCase(); - timer.cb(elTxt); + timer.cb(elTxt, timer.el); } } function watchElement(elem) { // Must be text or textarea - if (elem.type.toUpperCase() == "TEXT" || elem.nodeName.toUpperCase() == "TEXTAREA") { + if (elem.type.toUpperCase() == "TEXT" || elem.type.toUpperCase() == "PASSWORD" || elem.nodeName.toUpperCase() == "TEXTAREA") { // Allocate timer element var timer = { @@ -63,7 +63,7 @@ var overrideBool = false; // If enter is pressed then diretly execute the callback - if (evt.keyCode == 13 && this.type.toUpperCase() == "TEXT") { + if (evt.keyCode == 13 && (this.type.toUpperCase() == "TEXT" || this.type.toUpperCase() == "PASSWORD")) { timerWait = 1; overrideBool = true; }