我有更多jQuery Validation ajax。现在我想做一些验证:
我为此进行了jQuery验证的代码,如下所示:
$("#button_submit").attr("disabled", "true");
$("#accessories_sheet").keyup(function()
{
var accessories_sheet = $("#accessories_sheet").val();
var acc_no = $("#acc_no").val();
var revision = $("#revision").val();
var combine_part = $("#combine_part").val();
if(accessories_sheet.length >= 16)
{
$("#status_acc").html('<div class="pos_loader">Processing...</div>');
$.ajax(
{
type: "POST",
url: "check_accs.php",
data: 'accessories_sheet='+ accessories_sheet +'&acc_no='+ acc_no +'&revision='+ revision +'&combine_part='+ combine_part,
success: function(msg)
{
$("#status_acc").ajaxComplete(function(event, request, settings)
{
if(msg == 'OK')
{
$("#accessories_sheet").removeClass('object_error'); // if necessary
$("#accessories_sheet").addClass("object_ok");
$(this).html('<div class="notify success">OK</div>');
$("#box_pn").focus();
}
else
{
$("#accessories_sheet").removeClass('object_ok'); // if necessary
$("#accessories_sheet").addClass("object_error");
$(this).html(msg);
$("#accessories_sheet").focus();
$("#accessories_sheet").select();
$('#button_submit').attr("disabled", true);
}
});
}
});
}
else
{
$("#status_acc").html('<div class="notify errors">Accessories sheet length is 16 characters.</div>');
$("#accessories_sheet").removeClass('object_ok');
$("#accessories_sheet").addClass("object_error");
}
});
$("#box_pn").keyup(function()
{
var box_pn = $("#box_pn").val();
var combine_part = $("#combine_part").val();
var revision = $("#revision").val();
if(box_pn.length >= 12)
{
$("#status_box_pn").html('<div class="pos_loader">Processing...</div>');
$.ajax(
{
type: "POST",
url: "check_box_pn.php",
data: 'box_pn='+ box_pn +'&combine_part='+ combine_part +'&revision='+ revision,
success: function(msg)
{
$("#status_box_pn").ajaxComplete(function(event, request, settings)
{
if(msg == 'OK')
{
$("#box_pn").removeClass('object_error'); // if necessary
$("#box_pn").addClass("object_ok");
$(this).html('<div class="notify2 success">OK</div>');
$("#pack_label_pn").focus();
}
else
{
$("#box_pn").removeClass('object_ok'); // if necessary
$("#box_pn").addClass("object_error");
$(this).html(msg);
$("#box_pn").focus();
$("#box_pn").select();
$('#button_submit').attr("disabled", true);
}
});
}
});
}
else
{
$("#status_box_pn").html('<div class="notify2 errors">Box P/N length is 12 characters.</div>');
$("#box_pn").removeClass('object_ok');
$("#box_pn").addClass("object_error");
}
});
和文本框的HTML如下:
<form action="" method="post" autocomplete="off">
<input type="text" name="accessories_sheet" class="input_2" maxlength="16" id="accessories_sheet" onkeyup="javascript:this.value=this.value.toUpperCase();"/>
<td><input type="text" name="box_pn" class="input_2" maxlength="12" id="box_pn" onkeyup="javascript:this.value=this.value.toUpperCase();"/></td>
<input type="submit" value="Submit" id="button_submit"/>
任何建议伙伴们?请,需要你的帮助。