D
donpro
Hi,
I have a TEXTAREA where I wish to ensure that it contains at least on
4 digit number. The following code snippet always returns -1 even when
the 4 digit number is present and I don;t know why. Note that I first
ensure that the vale is not empty but I am not showing that code in
the snippet below.
var hsCodeElement = document.getElementById('TaField));
var hsCodePattern = '/^\d{4}$/';
if (hsCodeElement.value.search(hsCodePattern) == -1) {
alert(hsCodeElement.value.search(hsCodePattern) + ": HS Codes must
contain at least entered one 4 digit numeric value");
setTimeout(function() {hsCodeElement.focus();}, 10);
}
I have a TEXTAREA where I wish to ensure that it contains at least on
4 digit number. The following code snippet always returns -1 even when
the 4 digit number is present and I don;t know why. Note that I first
ensure that the vale is not empty but I am not showing that code in
the snippet below.
var hsCodeElement = document.getElementById('TaField));
var hsCodePattern = '/^\d{4}$/';
if (hsCodeElement.value.search(hsCodePattern) == -1) {
alert(hsCodeElement.value.search(hsCodePattern) + ": HS Codes must
contain at least entered one 4 digit numeric value");
setTimeout(function() {hsCodeElement.focus();}, 10);
}