Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. get input text value on text change

get input text value on text change

Scheduled Pinned Locked Moved JavaScript
javascripthtmlquestion
6 Posts 3 Posters 29 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shantanu Gupta 1337
    wrote on last edited by
    #1

    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"

    S 1 Reply Last reply
    0
    • S Shantanu Gupta 1337

      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"

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      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.

      S 1 Reply Last reply
      0
      • S Sandeep Mewara

        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.

        S Offline
        S Offline
        Shantanu Gupta 1337
        wrote on last edited by
        #3

        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.

        S 1 Reply Last reply
        0
        • S Shantanu Gupta 1337

          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.

          S Offline
          S Offline
          Sandeep Mewara
          wrote on last edited by
          #4

          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.

          S 1 Reply Last reply
          0
          • S Sandeep Mewara

            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.

            S Offline
            S Offline
            Shantanu Gupta 1337
            wrote on last edited by
            #5

            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

            N 1 Reply Last reply
            0
            • S Shantanu Gupta 1337

              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

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups