HTML5 のパターン関数で正規表現を使用しており、期待どおりに動作していますが、同じ関数を JQuery の .test 関数に入れると、期待どおりに動作しません。助言がありますか?
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#firstName').blur(function() {
if(!(/[A-Za-z']{3,14}/.test($('#firstName').val()))){
alert("thats not a good first name");
}
});
});
</script>
</head>
<input type="text"id="firstName" placeholder="first name" pattern="[a-zA-Z']{3,14}" />
<style type="text/css">input:valid{background:green;}input:invalid{background:red;}</style>