I put together a little validation function for you:
function validateRange(coordinate) {
// A little input validation
if (typeof coordinate != "string" || !coordinate.length)
return false;
// Find the first occurrence of a digit
var startIndex = coordinate.search(/[\d+]/);
// The column is the part from the beginning up until the first digit
var column = coordinate.substring(0, startIndex).toUpperCase();
// The row is the remainder of the string
var row = parseInt(coordinate.substring(startIndex), 10);
// The column is sortable alphabetically so we can check its range,
// and the row is numeric so we can check it's range as well
return (column >= "A" && row >= 1) &&
(column <= "XFD" && row <= 1048576);
}
Give it a whirl:
var str = "XFD100000";
var result = validateRange(str);
Applied to your context:
if (!validateRange(rangeFrom)) {
I don't know exactly how fool-proof this is, but maybe it would give you a good starting point.