【发布时间】:2015-09-10 10:40:29
【问题描述】:
我有一个包含许多字段的表单,其中一个就像当用户在输入字段中输入特定代码时,我需要在不提交表单的情况下检查该代码是否存在于数据库中。因为在表单上提交数据会被插入到另一个表中。我需要检查代码的表是不同的。如果代码退出,如果应该在文本框旁边显示代码是正确的,否则无效。有人可以给我提供相同或解决方案的例子....提前谢谢
MY_View:
<input type="text" name="ref_code" id="ref_code" onblur="checkCodeStatus()" size=18 maxlength=6 required>
<script type="text/javascript">
function checkCodeStatus(){
var ref_code=$("#ref_code").val();
$.ajax({
type:'post',
url:'<?php echo site_url('mypage/check_code/'); ?>',
data:{ref_code: ref_code},
success:function(msg){
alert(msg);
}
});
}
</script>
【问题讨论】:
标签: mysql ajax codeigniter validation textbox