Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Form validation on numeric values


Message #1 by "Shaukat Desai" <shaukat.desai@g...> on Sun, 19 Nov 2000 12:46:25 -0000
Hi,  

I have the following script which only allows numeric values, I want to be
able to allow for the delete key as well, can someone advise me on how I
can do this.

Thanks

Script:-

<SCRIPT language=javascript> 
var isIE = document.all?true:false;
var isNS = document.layers?true:false;

function OnlyDigits(e) {
	var bolOnlyDigits = true;
	
	if (isIE) {
		
		if (window.event.keyCode < 46 || window.event.keyCode > 57)
{
			window.event.keyCode = 0;
			bolOnlyDigits = false;
		}
		
	}
	
	if (isNS) {
		if (e.which < 46 || e.which > 57) {
			e.which = 0;
			bolOnlyDigits = false;
		}
	}
	
	return (bolOnlyDigits); 
}
</SCRIPT>

  Return to Index