This is my jQuery code:
$(document).ready(function(e) {
$('#step1 #fName').focus(function() {
$('#step1 #fName').keyup(function() {
var reg = /^([A-Za-z])$/;
var check = $('#step1 #fName').val();
if (reg.test(check) == true || check.match(reg) == true) {
$('#step1 #fName').css('border',' 1px solid #CCC');
}
else {
$('#step1 #fName').css('border',' 1px solid #b20000');
}
});
});
});
And I want to apply jQuery validation on this HTML tag:
<input type="text" class="width-260" id="fName"/>
How would I go about doing this? Thanks in advance.
You need to create a RegExp object, using new RegExp()…
Try with: