1
为什么在下面的代码不工作这部分if(!$(this).val()){...
从代码和这种匹配是真实的与http://www.st
,我想作为:http://stackoverflow.com
?Url验证与jquery
例子:http://jsfiddle.net/gp9nL/3/
$('.url').keyup(function(){
if (!$(this).val().match(/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \?=.-]*)*\/?$/)){
$(this).css("background", "#ffc4c4");
result = false;
}else {
$(this).css("background", "#FFFFEC");
result = true;
}
if(!$(this).val()){
alert('field is empty')
$(this).css("background", "#FFFFEC");
}
return result;
});
有什么解决办法? –
看到这里,在这里工作,但!!?:http://jsfiddle.net/gp9nL/2/ –
我已经用解决方案更新了答案,@艾丽西卡·希伯里 –