I have a function that creates multiple forms for a user input. At the bottom is this jquery statement
$('#divID'.on('click', 'nextButton', function() {
then the code goes through the form and collects the selected values into a local variable array currentAnswers. THe outer function then pushes the data to another variable to store all the answers. It seems the function was running twice which I noticed when the two sets of values were in currentAnswers- one set the selected answers and another the default. I had someone else look at the code and they said because of how jquery works each time the button is created the prior event listener is also there causing two clicks (I never tested it beyond two forms). He made some changes by adding a .off 'click' statement and a setTimeout. I was wondering if there is a simple way to kill the event listen .on 'click' when the function using it is exited. I hope this makes sense...
I am trying a form validation on click of a button. I expected to be able to traverse up using closest and then use find for each input field. It doesn't seem to be working. Also, in general, I am finding I can select an element just by id without any traversal. This is the jsfiddle code Thanks in advance.
I used this code from the jquery cookbook. It works too well in a sense. It does not accept any invalid input. However, I would like to give some feedback- a text message next to the box when they enter invalid code. I wanted to .after a span text warning but can't seem to find a good place to include in this code. Any help would be appreciated.