我有一个表单,我在我的网站上使用它,并验证了一些简单的JQuery验证。问题是,当我更改值时,它并没有提交或做任何事情。这里是我的代码:JQuery验证表单不提交
<form id="radForm" method="post" action="events.php?type=rad">
<div class="searchBoxLeft searchBoxRad"></div>
<div class="searchBoxMiddle">
<input id="radSearch" type="text" class="searchBoxInput searchBoxShort" value="<?php echo $yourradius; ?>" />
<label class="searchBoxLabel">Mile Radius of Your Address</label>
</div>
<div id="radButton" class="searchBoxRight"></div>
<div class="clearLeft"></div>
</form>
<script>
$(document).ready(function()
{
var radsearchok = 0;
//Rad search
$('#radSearch').blur(function()
{
var radsearch=$("#radSearch").val();
if(radsearch < 2){
$('#radSearch').addClass("searchError");
radsearchok = 0;
}
else if(radsearch > 50){
$('#radSearch').addClass("searchError");
radsearchok = 0;
}
else{
$('#radSearch').addClass("searchSuccess");
radsearchok = 1;
}
});
// Submit button action
$('#radButton').click(function()
{
if(radsearchok == 1)
{
$("#radForm").submit();
}
else
{
$('#radSearch').addClass("searchError");
}
return false;
});
//End
});
</script>
任何人都可以看到什么是错的呢?
['.VAL()'](http://api.jquery.com/val/)返回一个字符串 - > ['.parseInt ()'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)将成为你的朋友:) – Andreas
谢谢@Andreas,我编辑了代码。尽管如此,仍然不能解决我最初的问题。我已经多次使用这个相同的脚本,没有任何问题,但这次它只是不工作,我不明白为什么? – user2737457
http://jsfiddle.net/zdeZ2/1/ - 做了一些更改,它适用于我 – megawac