Numeric Range Validation PLEASE HELP ASAP

Discussion in 'JavaScript' started by gtaro, Oct 6, 2006.

  1. #1
    I am trying to update the code you see below with Numeric Validtion. This is a function that is called to verify a numeric field. But for my life I cant figure it out. I have attached the code below. All I am trying to do is update the code to allow a numeric range from 0 - 35000.. But still have the function do what it is already doing. Please help ASAP, I have to get this working by this afternoon. PLEASE HELP.. THANKS GUYS!

     function DrawNumericValidation(source, args){
    	var tb = source.id.split("-")[0];
    	var txt = document.getElementById(tb).value;
    	txt = txt.replace(/ /g,"");
    	document.getElementById(tb).value = txt;
    
    	args.IsValid = true;
    
    	if (txt == null  ||  txt.length == 0) {
    		args.IsValid = true;
    	}
    	else {	
    		for (var i = 0; i < txt.length; i++) {
    			var c = txt.charCodeAt(i);
    			if ((c < 48 || c > 57)  &&  c != 46) {
    				args.IsValid = false;
    			}
    		}
    	} 
    Code (markup):

     
    gtaro, Oct 6, 2006 IP