Hello,
I can program only in PHP, so I would appreciate a little help with this simple script.
Imagine a page with twenty inputs.
All I need is check, if user type in input some of specified words - in array I would like to save five or six words (different for every input) and if user type some of specified words (for this exact input) something happen - like replacing input with confirming image (that he's right).
And repeat that last part for field2 etc. Alternatively, you could change 'blur' to 'keyup' if that is what you are looking for. Hopefully this helps you get started.
Mike
Last edited by dmikester1; 08-30-2012 at 10:26 AM.
I never worked with jQuery. So I downloaded that library or what is it, rename it to jquery.js and in the same folder put file with this content. But it's not working?
Well, that was all just sample code that I gave you to get started. You'll have to change the variable names and fit it into your current code. Do you have the html with the 20 inputs already created?
Well, that was all just sample code that I gave you to get started. You'll have to change the variable names and fit it into your current code. Do you have the html with the 20 inputs already created?
No, I didn't create anything yet. At first I wanna have functional script. And after that build some application on it.
I really don't have a clue which variable to change, because names of inputs and everything looks ok for me.
Well, it would really help if you built your HTML first. Because if your 20 input id's are input1, input2, input3, etc then you would need to change the variable in my code from 'field1' to 'input1'. The other field I made up that you would have to change to match your code is 'specialImage1'.
Does that make sense?
just a note before you get sidetracked into thinking that jQuery has some magical properties that plain js doesn't. Have a look at the same code in normal js:
simpler, huh? and it saves you from having to load the entire jQuery library just for this trivial task...
dmikester1: Depending on case use, indexOf may not be the best method here - try entering "chappy" or "Mossad" into your input boxes and you'll see what I mean.
Last edited by xelawho; 08-30-2012 at 07:04 PM.
Reason: clarification
And would be possible to count number of correct inputs? Like at the beginning 0/20 and after user fill one input change it to 1/20.
I think it's pretty easy, cause after filling input (if you're correct) this input disappear. So i't only about attributing number one to some variable. Unfortunately I can't program in javascript... .
Bookmarks