I am trying to convert a html onkeypress event handler to an event listener. 
I want to prevent alpha characters from being entered in an element where the information must be restricted to money ie: 1.23,
I was able to do that with this simple event handler on the html:
	using this javaScript code, the errant keystroke is not recorded.
	However when I assign an event listener using the same code, it still captures the errant key stroke but after my alert message the key stroke appears anyway. Here is my event listener code:
	Here is the javaScript code
	This code branches to the same function listed above, but the key stroke is not suppressed. Why is that?
							
						
					I want to prevent alpha characters from being entered in an element where the information must be restricted to money ie: 1.23,
I was able to do that with this simple event handler on the html:
Code:
	<input type="text" id="AMOUNT" onkeypress="return exp.isMoney(event)" />
Code:
		this.isMoney = function(evt){
		evt = (evt) ? evt : event; 
		var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :  
			((evt.which) ? evt.which : 0)); 
		var eventCode = evt.keyCode
		//allow navigation to correct errors
		if ( !this.isNavigation(eventCode) )
		{
			if ((charCode > 32 && (charCode < 48 || charCode > 57)) && charCode != 46)  
			{ 
					alert("Not a number."); 
			return false; 
			}
		} 
		return true; 
	};
Code:
	<input type="text" id="AMOUNT" size="10" />
Code:
	function load(){
	var amount = document.getElementById('AMOUNT');
	 amount.addEventListener("keypress", function(evt){exp.isMoney(evt)},false);
	return;
}
Comment