get input text value on text change
-
well, this seems to be a silly question but is getting on my nerves -.- i am working with Javascript and Jquery, i have a password tag which is not nested in a form, i want to check wether the input matches a constant defined by me when typed by user and length = 4 here goes my current code :
PIN: Validate
I dont know PIN, go to Public Page >>i had to add " to div, else it would just show "pin"
-
well, this seems to be a silly question but is getting on my nerves -.- i am working with Javascript and Jquery, i have a password tag which is not nested in a form, i want to check wether the input matches a constant defined by me when typed by user and length = 4 here goes my current code :
PIN: Validate
I dont know PIN, go to Public Page >>i had to add " to div, else it would just show "pin"
Shantanu Gupta 1337 wrote:
but is getting on my nerves
Which part of it is gettng on your nerves? You already have tied 'check()' javascript method on button click.
//define a JS
function check()
{
// verify if text entered in password field matches your pin. Done!
}BTW: Why have you defined 'onchange="showValue(this);' for password field? It doesn't make sense here based on other control validating it.
-
Shantanu Gupta 1337 wrote:
but is getting on my nerves
Which part of it is gettng on your nerves? You already have tied 'check()' javascript method on button click.
//define a JS
function check()
{
// verify if text entered in password field matches your pin. Done!
}BTW: Why have you defined 'onchange="showValue(this);' for password field? It doesn't make sense here based on other control validating it.
it is not for validating, it is for checking if the code entered is same as that defined by me on a file located in ../public_html/ so that it cannot be accessed and value is called when Jsp needs it using the part getting on my nerve is, the event does not fire onchange (when i type) but when i close the tab with data in it, it suddenly pops up with the correct answer if it is alert($('#pinin').val())); what i want is when the len of pinin reaches 4, it checks if its value is equal to my const. and if true display a alert or redirect.
-
it is not for validating, it is for checking if the code entered is same as that defined by me on a file located in ../public_html/ so that it cannot be accessed and value is called when Jsp needs it using the part getting on my nerve is, the event does not fire onchange (when i type) but when i close the tab with data in it, it suddenly pops up with the correct answer if it is alert($('#pinin').val())); what i want is when the len of pinin reaches 4, it checks if its value is equal to my const. and if true display a alert or redirect.
Shantanu Gupta 1337 wrote:
the event does not fire onchange (when i type)
Dude, onchange will only fire once the focus goes away from the textbox! If you need to check at the time of entering data then use 'onKeyUp' instead of onchange.
-
Shantanu Gupta 1337 wrote:
the event does not fire onchange (when i type)
Dude, onchange will only fire once the focus goes away from the textbox! If you need to check at the time of entering data then use 'onKeyUp' instead of onchange.
thank you mate, that did just the trick i was looking for. Gosh W3C didnt mention that event for textbox, will remember this. Thanks again..
function check(obj) { var pin1 = parseStr(obj.value); if (pin1.length == 4) { // Will obfuscate PIN using hashes in later builds... if (pin1 == "3924") { <?php setcookie... ?> window.alert('Welcome master, Redirecting you'); setTimeout(function() { document.location ='main.php'; }, 2000); } else { <?php setcookie... ?> window.alert('Invalid Pin, Rerouting to Public Page.'); setTimeout(function() { document.location ='publ.php'; }, 2000); } } }
Just in case you were wondering why i used master, This is still in development and i like being treated like a Master... xP
modified on Sunday, August 8, 2010 1:09 PM
-
thank you mate, that did just the trick i was looking for. Gosh W3C didnt mention that event for textbox, will remember this. Thanks again..
function check(obj) { var pin1 = parseStr(obj.value); if (pin1.length == 4) { // Will obfuscate PIN using hashes in later builds... if (pin1 == "3924") { <?php setcookie... ?> window.alert('Welcome master, Redirecting you'); setTimeout(function() { document.location ='main.php'; }, 2000); } else { <?php setcookie... ?> window.alert('Invalid Pin, Rerouting to Public Page.'); setTimeout(function() { document.location ='publ.php'; }, 2000); } } }
Just in case you were wondering why i used master, This is still in development and i like being treated like a Master... xP
modified on Sunday, August 8, 2010 1:09 PM
Shantanu Gupta 1337 wrote:
W3C didnt mention that event for textbox
:wtf: It's covered in just about every JavaScript reference resource :wtf:
I know the language. I've read a book. - _Madmatt