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)里?
我无从下手了!

解决方案 »

  1.   

    我想 当失去焦点 时候就要出现提示输入的是否是合法身份证号的提示。 而不是在点击 按钮时大侠们帮忙啊!还有工程session被重写,不能用session了 
      

  2.   

    就是说利用onblur事件:获取输入的身份证号,然后通过ajax发送到后台,后台接收数据,再查询数据库看是否有该ID,再把信息返回给客户端。输出提示信息。自己去看看ajax。不难!
      

  3.   

    Jquery Ajaxfunction check_id(o){
      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}';
    }
      

  4.   

    $.get(url,{params:datas},function(returnMsg){
    if(returnMsg=="exists"){
    alert();
    }
    });
      

  5.   

    具体点就是用jquery的$('#id').load('url','id:xxxxxx','callback')
    id用post传递
      

  6.   

    具体点就是用jquery的$('#divid').load('url','id:xxxxxx','callback')
    id用post传递
      

  7.   

    推荐一个ajax的视频教程给你,看了保证会http://www.php100.com/html/shipinjiaocheng/PHP100shipinjiaocheng/2009/0525/2942.html
      

  8.   

    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>
      

  9.   

    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>
      

  10.   

    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>