a.php<script>
<form action ='本页.php' method='post'>
..这里有很多<input>
<td align="right">身份证号:</td>
<td align="left"> <input type = "text" maxlength="18" name = "sIDcard" onBlur="check_id(this)"/></td>
<td>
<label style="color:red;font-size:12px" value='3'id="lbl_7"></label>
</td>
...
<input type='submit' /> //点击时post全部<input>的值。并执行数据库插入语句
</form>function check_id(obj)
{
var idcard = obj.value.replace(/(^\s*)|(\s*$)/g, '');
alert("<?php echo $_GET['sIDcard'];?>");
<?php
if(idcard_check($_POST['sIDcard']))
echo 'document.getElementById("lbl_7").innerHTML="√";';
else
echo 'document.getElementById("lbl_7").innerHTML="×";';
?>
}
</script>验证函数
function.php
function check(id)
{
if(身份证)
return true;
else
return false;
}现在的问题是,当sIDcard 文本框失去焦点后运行check_id(obj)函数时如何把 文本框的值 传到php函数check(id)里?
我无从下手了!
<form action ='本页.php' method='post'>
..这里有很多<input>
<td align="right">身份证号:</td>
<td align="left"> <input type = "text" maxlength="18" name = "sIDcard" onBlur="check_id(this)"/></td>
<td>
<label style="color:red;font-size:12px" value='3'id="lbl_7"></label>
</td>
...
<input type='submit' /> //点击时post全部<input>的值。并执行数据库插入语句
</form>function check_id(obj)
{
var idcard = obj.value.replace(/(^\s*)|(\s*$)/g, '');
alert("<?php echo $_GET['sIDcard'];?>");
<?php
if(idcard_check($_POST['sIDcard']))
echo 'document.getElementById("lbl_7").innerHTML="√";';
else
echo 'document.getElementById("lbl_7").innerHTML="×";';
?>
}
</script>验证函数
function.php
function check(id)
{
if(身份证)
return true;
else
return false;
}现在的问题是,当sIDcard 文本框失去焦点后运行check_id(obj)函数时如何把 文本框的值 传到php函数check(id)里?
我无从下手了!
var id= $(o).attr('value'); $.ajax({
type: "post",
dataType: 'json',
url: "check.php",
data: "id="+id,
success: function(msg){
if(msg.success === true){
alert('成功');
} else {
alert('失败');
}
}
});
}
check.php
$id = $REQUEST['id'];
//通过ID来判断是否存在
if('存在'){
echo '{success:false}';
}else {
echo '{success:true}';
}
if(returnMsg=="exists"){
alert();
}
});
id用post传递
id用post传递
..这里有很多<input>
<td align="right">身份证号:</td>
<td align="left"> <input type = "text" maxlength="18" name = "sIDcard" onBlur="check_id(this)"/></td>
<td>
<label style="color:red;font-size:12px" value='3'id="lbl_7"></label>
</td>
...
<input type='submit' /> //点击时post全部<input>的值。并执行数据库插入语句
</form>
..这里有很多<input>
<td align="right">身份证号:</td>
<td align="left"> <input type = "text" maxlength="18" name = "sIDcard" onBlur="check_id(this)"/></td>
<td>
<label style="color:red;font-size:12px" value='3'id="lbl_7"></label>
</td>
...
<input type='submit' /> //点击时post全部<input>的值。并执行数据库插入语句
</form>
..这里有很多<input>
<td align="right">身份证号:</td>
<td align="left"> <input type = "text" maxlength="18" name = "sIDcard" onBlur="check_id(this)"/></td>
<td>
<label style="color:red;font-size:12px" value='3'id="lbl_7"></label>
</td>
...
<input type='submit' /> //点击时post全部<input>的值。并执行数据库插入语句
</form>