jquery form BASIC validation question -


I am trying to validate a form if there is no text in the input field, an error icon pops up it happens .. . And if anything is in input then a successful icon pops up. There are no true verification methods being used. You can see the form.

As you can see, when you type something in the first field and you press the tab, the icon is decided correctly, but it will not work on any field after the first. Here's my junkie:

  & lt; Script type = "text / javascript" & gt; $ (Function () {var field = document.getElementById ('myFormField'); var icon = document.getElementById ('myIcon'); field.onchange = function () {icon.src = this.value? 'Success.png ':' Fail.png ';};}); & Lt; / Script & gt;  

I do not know how it works on all input fields, but I'm sure it's a simple fix. My HTML is set to:

  & lt; Input type = "text" class = "name" name = "name" tabindex = "1" id = "myFormField" /> & Lt; Img id = "myIcon" />  

id triggers the icon myFormfield, and the class triggers the background of the "name" click. I think I should stay with the class and try to use it as a part of this solution. Any ideas?

Try to do something that you are not actually using the power of jQuery:

  $ (function () {$ (': text,: textarea'). Bind ('change, blurring', function () {$ (this) .next ('IMG'). Et ('src', this.value? 'Success.png': 'fail.png');});});  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -