I have a form in which a user is to fill out a textbox. If he leaves it empty, an error message gets displayed. My definition of empty though is any number of spaces without anything else.
Here's my code:
$(document).ready(function(){
$("#groupName").blur(function(){
if($('#groupName').val().match(/^[[:space:]]*$/))
{
$("#ajaxError").html("Group Name field must be supplied");
$("#errorField").html("");
}
else
{
$("#ajaxError").html("");
$("#errorField").html("");
}
});
});
I should note, it worked fine when I wasn't trying to do a regular expression, so I know it is the regular expression that is the problem. This worked:
$(document).ready(function(){
$("#groupName").blur(function(){
if($('#groupName').val() == "")
{
$("#ajaxError").html("Group Name field must be supplied");
$("#errorField").html("");
}
else
{
$("#ajaxError").html("");
$("#errorField").html("");
}
});
});
What's going wrong? Thanks for the help!
This post has been edited by eZACKe: 13 June 2011 - 09:25 AM

New Topic/Question
Reply



MultiQuote


|