我在我的项目中遇到了这种类型的问题。我正在研究 asp.net 应用程序,它是一个工作门户,所以候选人的电子邮件 ID 是唯一的,所以我这样检查并解决这个问题。它在下面
在表格中
<div id="dvErrorMessage" style="display: none;" title="Message">
<p>
Please Registered with different EmailId.This is allready exists.</p>
</div>
$("#txtEmailID").blur(function (e) {
if (document.getElementById("txtEmailID").value == "") {
document.getElementById("txtEmailID").focus();
document.getElementById("lblEmailID").innerHTML = "Please Enter Email ID";
document.getElementById("imgEmailID").src = "images/cross-sign.png";
}
else {
e.preventDefault();
var EmailID = $("#txtEmailID").val();
var url = "JsonData.asmx/GetCompanyEmailAccessbility";
var emailformate = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
$.ajax({
type: "POST",
url: url,
contentType: "application/json; charset=utf-8",
dataType: 'json',
data: '{EmailID:"' + EmailID + '"}',
success: function (msg) {
var data = msg.d;
if (data == 0) {
if (emailformate.test(document.getElementById("txtEmailID").value) == false) {
document.getElementById("imgEmailID").src = "images/cross-sign.png";
document.getElementById("lblEmailID").innerHTML = "Please Enter Valid Email ID";
document.getElementById("txtEmailID").focus();
return false;
}
else {
document.getElementById("imgEmailID").src = "images/right-sign.png"
}
}
else {
if ($("#dvErrorMessage").css('display') == 'none') {
$("#dvErrorMessage").css('display', 'block');
$("#dvErrorMessage").dialog({
autoOpen: false,
modal: true,
width: 400,
resizable: false,
height: 200,
buttons: {
"OK": function (e) {
e.preventDefault();
$(this).dialog('close');
document.getElementById("txtEmailID").focus();
document.getElementById("imgEmailID").src = "images/cross-sign.png";
}
}
});
$("#dvErrorMessage").dialog('open');
}
else {
$("#dvErrorMessage").dialog({
autoOpen: false,
modal: true,
width: 400,
resizable: false,
height: 200,
buttons: {
"OK": function (e) {
e.preventDefault();
$(this).dialog('close');
document.getElementById("txtEmailID").focus();
document.getElementById("imgEmailID").src = "images/cross-sign.png";
}
}
});
$("#dvErrorMessage").dialog('open');
}
}
}
});
}
});
}
在我的网络服务中
public List<CompanyData> GetCompanyEmailAccessbility(string EmailID)
{
PresenterData objpreseData = new PresenterData();
LMGDAL.db_LMGEntities dbData = new db_LMGEntities();
var dataAccessibility = dbData.tblCompanies.Where(x => x.CompanyEmailId == EmailID).ToList().Select(item => new CompanyData { EmailID = item.CompanyEmailId }).ToList();
return dataAccessibility.ToList();
}