I'm checking the first character of a string for any non-alphanumeric characters from a multi-line textbox. If I pass in this string in, I get some hits.
ATest
BTest2
CAnother1
DThen some
2 More to go
FAny other some-day
Here's the javascript code:
function CheckFirstAlphaNum(textToTest, valueLabel, pattern, warningMessage)
{
var textValues = textToTest.split("\n");
pattern = pattern || /([A-Za-z0-9]+)/gm;
warningMessage = warningMessage || "The first character of a value in '" + valueLabel + "' has an invalid character. Please consider revising it."
var goodText = true;
for (var i = 0; i < textValues.length; ++i) {
//alert(textValues[i]);
var firstChar = textValues[i].substring(0, 1);
if (!pattern.test(firstChar)) {
alert(firstChar);
alert(pattern);
goodText = false;
}
}
if (goodText != true) { alert(warningMessage); }
return goodText;
}
Any ideas why? It fails on B, D, and F, so it seems like every other line.