用户ID存在时,jQuery不执行回发 [英] jquery not to do postback when user id existing

查看:60
本文介绍了用户ID存在时,jQuery不执行回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JQuery来验证数据库中是否存在用户.

功能如下:

I am using JQuery to validate whether user is existing in the database.

The function is as follows:

function CheckUserID() {
           var Email;
           Email = $('#<%=txtEmail.ClientID%>').val();
           Page_ClientValidate();
           if (Page_IsValid) {
               ValidatorEnable(document.getElementById('<%=reqName.ClientID %>'), false);
               ValidatorEnable(document.getElementById('<%=reqEmail.ClientID %>'), false);
               $.ajax({
                   type: "GET",
                   async: false,
                   url: "CkeckUser.aspx",
                   data: "UID=" + Email,
                   cache: false,
                   success: function(resultMsg) {
                       $('#<%=hdnEmailID.ClientID%>').val($(resultMsg).find("#divEmail input[type='hidden']").eq(0).val());
                       if ($('#<%=hdnEmailID.ClientID%>').val() == '1') {
                           $('#<%=lblMsg.ClientID%>').text('Users exists');
                           return false;
                       }
                       else {
                           $('#<%=lblMsg.ClientID%>').text('Users doesnot exists');
                           return true;
                       }
                   },
                   error: function(msg) {
                       alert("Error");
                   }
               });
           }
           else {
               ValidatorEnable(document.getElementById('<%=reqName.ClientID %>'), true);
               ValidatorEnable(document.getElementById('<%=reqEmail.ClientID %>'), true);
               $('#<%=lblMsg.ClientID%>').text('');
           }
       }




它检查用户是否存在(如果用户存在,则将显示msg ..user存在..并回发以将值插入数据库).

当用户存在于数据库中时,任何人都可以提供帮助(避免回发).

谢谢
yashoda




It checks for the user existence (if user is existing it will show msg ..user exists.. and does postback to insert the value in database).

Any one can help (to avoid doing postback) when user is existing in database.

Thank you,
yashoda

推荐答案

(' #<%= txt电子邮件.ClientID%>').val(); Page_ClientValidate(); 如果(Page_IsValid){ ValidatorEnable(文档 .getElementById(' <%= reqName .ClientID%>'), false ); ValidatorEnable(文档 .getElementById(' <%= reqEmail .ClientID%>'), false );
('#<%=txtEmail.ClientID%>').val(); Page_ClientValidate(); if (Page_IsValid) { ValidatorEnable(document.getElementById('<%=reqName.ClientID %>'), false); ValidatorEnable(document.getElementById('<%=reqEmail.ClientID %>'), false);


.ajax({ 类型:" , 异步:错误, url:" , 数据:" +电子邮件, 缓存: false , 成功:功能(resultMsg){
.ajax({ type: "GET", async: false, url: "CkeckUser.aspx", data: "UID=" + Email, cache: false, success: function(resultMsg) {


(' #<%= hdnEmailID.ClientID%>').val(


这篇关于用户ID存在时,jQuery不执行回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆