douyan6742 2014-02-20 15:08
浏览 33

在表单上提交重定向到同一页面 - 查询验证引擎

I have implemented jquery validation engine plugin for form validations. The problem is with ajax validation for input. Whenever the form is submitted or submit button is clicked before the ajax success message is shown, it is redirecting to same page, which means the php script on form submit is not calling.

eg:

I have a email field

<input class="validate[required,ajax[EmailCallPhp]]" type="text" name="email" />

When we enter the email and click submit button immediately before and any success/error if the ajax returns false form is not submitted but if its successful, it submits the form but the php script on form submit does not work and redirects to same page..

$(document).ready(function(){

    $("#RegFb").validationEngine();

});

code calls ajax:

"EmailCallPhp": {
    "url": "valEmail.php",  //register email validation
     // you may want to pass extra data on the ajax call
    "extraData": "name=eric",
      // if you provide an "alertTextOk", it will show as a green prompt when the field validates
    "alertTextOk": "* OK",
    "alertText": "* Email Already Exist",
    "alertTextLoad": "* Validating, please wait"
            }

valEmail.php code

$email=$_REQUEST['fieldValue'];
$emailId=$_REQUEST['fieldId'];


$validateError= "This username is already taken";
$validateSuccess= "This username is available";


/* RETURN VALUE */
$arrayToJs = array();
$arrayToJs[0] = $emailId;

$stmt = $db->prepare("SELECT email FROM table WHERE email = :email");
$stmt->execute(array(':email'=>$email));

if($stmt->rowCount() == 0){     // validate??
$arrayToJs[1] = true;           // RETURN TRUE
echo json_encode($arrayToJs);           // RETURN ARRAY WITH success
}else{
for($x=0;$x<1000000;$x++){
    if($x == 990000){
        $arrayToJs[1] = false;
        echo json_encode($arrayToJs);       // RETURN ARRAY WITH ERROR
    }
}

}

Thanks!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line