The following code always populates the "$ is undefined alert message in JavaScript". Please do help me out with this. Thanks in advance Code for Script tag:
function CheckString() {
try{
var s = "";
s=$('#regExString').val();
alert(s);
var regExpression = /^[A-Z,a-z]\d[A-Z,a-z][\s{1}]?\d[A-Z,a-z]\d/;
if (regExpression.test(s))
alert("Valid postal code.");
else
alert("Invalid postal code.");
} catch (e) {
alert(e.message);
}
}
The html input text tag is passed as the text field and button has on click function CheckString which validates the regular expression
Aucun commentaire:
Enregistrer un commentaire