我正在使用 jquery 步骤作为表单向导,我需要在表单向导内的字段中实现 jquery UI 的自动完成,但是自动完成不起作用,当我将字段从表单中取出时,它可以工作,这是我使用的代码
<script>
$(function (){
var availableTags = [""];
$("#wizard").on('keyup','.tags',function () {
$.post('LinkingPages', {Request : 'GetAirports',StartWith : $(this).val()}, function(data) {
var Tab = data.split(";");
var i;
for (i = 0; i < Tab.length; i++) {
availableTags[i] = Tab[i];
}
for (var j = i; j < availableTags.length; j++) {
availableTags[j]="";
}
},"text");
});
$('.tags').autocomplete({
open: function() {alert("Hello");},
source : availableTags
});
$("#wizard").steps({
headerTag: "h3",
bodyTag: "span",
transitionEffect: "slideLeft",
stepsOrientation: "vertical",
onStepChanging: function (event, currentIndex, newIndex)
{
$("#SendReqForm").validate().settings.ignore = ":disabled,:hidden";
return $("#SendReqForm").valid();
},
onFinishing: function (event, currentIndex)
{
$("#SendReqForm").validate().settings.ignore = ":disabled";
return $("#SendReqForm").valid();
},
onFinished: function (event, currentIndex)
{
$("#SendReqForm").submit();
}
});
function errorPlacement(error, element)
{
element.before(error);
}
$("#SendReqForm").validate({
//errorLabelContainer: '#errors',
errorPlacement: errorPlacement,
rules: {
Co_Password: {
equalTo: "#password"
},
Co_Email: {
equalToEmail: "#Email"
},
Password:{
pwdComp:true
}
}
});
jQuery.validator.addMethod("pwdComp", function(input,element, param) {
var reg = /^[^%\s]{6,}$/;
var reg2 = /[a-zA-Z]/;
var reg3 = /[0-9]/;
return reg.test(input) && reg2.test(input) && reg3.test(input);
},
jQuery.validator.format("For security reasons passwords must include a capital letter, small letter, number and be more than 6 characters."));
});
</script>