Avatar of Richard Korts
Richard Korts
Flag for United States of America

asked on 

Javascript not working?

see this code:
	function isdigit(test) {
		if (test == "0" || test == "1" || test == "2" ||
	    	test == "3" || test == "4" || test == "5" ||
	    	test == "6" || test == "7" || test == "8" ||
	    	test == "9" || test == ".")
			return true;
		else {
			return false;
	     }
	}
// Function to determine if a field is numeric
	function isnumeric(field) {
		len = field.length;
		for (i = 0; i < len; i++)
			if (isdigit(field.charAt(i)) == false) {
				return false;
			}
		return true;
	}

Open in new window


and
pp6 = pp5.trim();
				alert("pp6 = " + pp6);
				pnl = pp6.length;
				alert("pnl = " + pnl);
				if (pnl > 11) {
					alert ("Invalid phone number.");
					return false;
				}
				if (! isnumeric(pp6)) {
					alert ("pp6 not numeric");
					alert ("Invalid phone number.");
					return false;
				}

Open in new window

In a specific case, pp5 is 6198559182

The alerts show pnl is 11 (impossible) and pp6 is NOT numeric (impossible).

What am I missing.

FYI, this was working a week or so ago; I am using Firefox, they just did a seemingly MAJOR update. I have not tried in Chrome. Could that be the problem? To my knowledge I have made no other changes (the date before I put in all the alerts was 11/21/17).
JavaScript

Avatar of undefined
Last Comment
Richard Korts

8/22/2022 - Mon