function validtext(template_str,txt) {

	// # = 0-9
	// A = A-Z
	// a = a-z
	// C = A-Z or a-z
	// S = 0-9 or A-Z or a-z
	// + = + or -
	// else literal match

	var template_len = template_str.length;
	var txt_len = txt.length;
	if (txt_len != template_len) {
		return false;
	}

	for ( i = 0; i < template_len; i++ ) {
		if (template_str.charAt(i)=="#") {
			if (txt.charCodeAt(i) < 48 || txt.charCodeAt(i) > 57) {
				return false;
			}
		} else if (template_str.charAt(i)=="A") {
			if (txt.charCodeAt(i) < 65 || txt.charCodeAt(i) > 90) {
				return false;
			}
		} else if (template_str.charAt(i)=="a") {
			if (txt.charCodeAt(i) < 97 || txt.charCodeAt(i) > 122) {
				return false;
			}
		} else if (template_str.charAt(i)=="C") {
			if ((txt.charCodeAt(i) < 65 || txt.charCodeAt(i) > 90) && (txt.charCodeAt(i) < 97 || txt.charCodeAt(i) > 122)) {
				return false;
			}
		} else if (template_str.charAt(i)=="S") {
			if ((txt.charCodeAt(i) < 48 || txt.charCodeAt(i) > 57) && (txt.charCodeAt(i) < 65 || txt.charCodeAt(i) > 90) && (txt.charCodeAt(i) < 97 || txt.charCodeAt(i) > 122)) {
				return false;
			}
		} else if (template_str.charAt(i)=="+") {
			if ((txt.charCodeAt(i) != 43) && (txt.charCodeAt(i) != 45)) {
				return false;
			}
		} else {
			if (txt.charCodeAt(i) != template_str.charCodeAt(i)) {
				return false;
			}
		}
	}
	return true;
}
