[Javascript] Form change

Triche Osborne wdlists at triche-osborne.com
Mon May 29 08:35:38 CDT 2006


Peter Lauri wrote:
> Best group member,
> 
> This is my first message to this Mailing List, and this question has
> probably been discussed, but I did not find any search function in the
> archive at https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> I have a form that I do some check via JavaScript. When the form gets focus
> or loses focus I would like to do check the input fields. This is how I do
> it now:
> 
> <form>
> <input onChange="checkFormData();">
> <input onChange="checkFormData();">
> <input onChange="checkFormData();">
> </form>
> 
> But I would like it to be:
> <form onChange="checkFormData();">
> <input>
> <input>
> <input>
> </form>
> 
> According to reference material online (w3schools.com) there is no function
> to execute script if form has been changed.
> 
> Have I been searching in the wrong reference materials? Or can this be done?
> 
Hi Peter,

The W3C standard specifies onchange for INPUT, SELECT and TEXTAREA tags. 
There is no onchange event for FORM.

If your goal is simply to attach the onchange to every field within the 
form, you can use an unobtrusive method of doing it in an onload 
handler. If this is the only form on the page, grab the tags by tag name 
and attach the event.

If you're trying to migrate to a completed form check (as opposed to a 
field-by-field check), use onsubmit instead.

Triche




More information about the Javascript mailing list