我想使用Jquery進行數量驗證。我要檢查以下AJAX數量Validation
1)該數字爲整數
2),它不信
3)他們是不是小數
4)最大數量爲99
我目前的jQuery的
$(document).ready(function()
{
$('#button').click(function()
{
var pid = $('#pid').val();
var length = $('#length').val();
var Qty = $('#Qty').val(); // this is the quantity
var Category = $('#Category').val();
#Qty = preg_replace('#[^0-9]#i', '', $Qty); // filter everything but numbers
if ($Qty >= 100) { $Qty = 99; }
if ($Qty < 1) { $Qty = 1; }
if ($Qty == "") { $Qty = 1; }
$.ajax({
url: 'cart.php',
type: 'POST',
data: { pid:pid, length:length, Qty:Qty, Category:Category },
success: function(data)
{
}
})
});
});
@saran班納吉你能幫助我這個請 – Amy
@nnnnnn我的意思是如果有人類型,如'0.6' – Amy
@nnnnnn做我以前'$阿賈克斯({ URL把這個:「cart.php」, 型:'POST',' – Amy