| Programming | Newsgroup Tips & Tricks | CubeCart Stuff |
| Subject: Re: OnChange Event |
| From: RobG |
| Date: Tue, 23 Aug 2005 23:44:25 GMT |
| Newsgroups: comp.lang.javascript |
| X-Mozilla-Status: 0011 |
| X-Mozilla-Status2: 00000000 |
| Path: bigbe2.bellsouth.net!bigfeed.bellsouth.net!news.bellsouth.net!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!news.xtra.co.nz!news-south.connect.com.au!news1.optus.net.au!optus!news.optus.net.au!53ab2750!not-for-mail |
| User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) |
| X-Accept-Language: en-us, en |
| MIME-Version: 1.0 |
| Newsgroups: comp.lang.javascript |
| References: <1124828901.038519.208610@g44g2000cwa.googlegroups.com> |
| In-Reply-To: <1124828901.038519.208610@g44g2000cwa.googlegroups.com> |
| Content-Type: text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding: 7bit |
| Lines: 37 |
| Message-ID: |
| NNTP-Posting-Host: 203.15.126.10 |
| X-Trace: news.optus.net.au 1124840665 203.15.126.10 (Wed, 24 Aug 2005 09:44:25 EST) |
| NNTP-Posting-Date: Wed, 24 Aug 2005 09:44:25 EST |
| Xref: bigfeed.bellsouth.net comp.lang.javascript:577550 |
crjunk wrote:
onchange should fire when the element loses focus if its value has changed. In some circumstance it fires earlier - different circumstances in different browsers on different elements - but its behaviour for input elements is pretty standard.
The only key press that should cause an onchange on a text input to fire is one that moves focus off the element.
Having both onblur and onchange on the same control may create issues, you will need to test thoroughly to ensure consistent behaviour.
I have a javascript that will output a message telling the user that
changes were made. It halfway works. If the user enters in a number,
the TextChanged function executes and displays the "Changes Made"
message, but if the user deletes a number by using the BACKSPACE key or
the DELETE key on the keyboard, the function does not run. Am I using
the wrong event handler?
onchange should fire when the element loses focus if its value has changed. In some circumstance it fires earlier - different circumstances in different browsers on different elements - but its behaviour for input elements is pretty standard.
The only key press that should cause an onchange on a text input to fire is one that moves focus off the element.
Having both onblur and onchange on the same control may create issues, you will need to test thoroughly to ensure consistent behaviour.
function TextChanged(){
document.ScheduleForm.txtRecordStatus.value = "Changes Made; Record Not
Saved.";
document.ScheduleForm.txtRecordStatus.style.color = "#FF0000";
}
<input type='text' name='txtGrossPayroll1' value='1' width='10'
onBlur='TotalPremium(7)' onkeyup='ComputePremium(1)'
onchange='TextChanged()' onkeypress='return blockNumbers(event)'/>
Thanks,
CR Junk
--
Rob
Rob