我想通過文本框上的鏈接模糊函數。通過模糊功能鏈接而不是點擊另一個鏈接
jQuery代碼
<a id="checkEmail" href="#" ></a> | <a id="getCandidate"></a> */* this is the link for get the profile details*/*
<script type ="text/javascript">
$('#getCandidate').text('Get Profile') // Sets text for email.
.attr('href', '#');
$("#Email").blur(function() {
$('#checkEmail').trigger('click');
//$('#checkEmail').trigger('GetCandidateDetail?validateEmail=' + $('#Email').val());
$('#getCandidate').text('Get Profile')
.attr('href', 'GetCandidateDetail?validateEmail=' + $('#Email').val());
});
$(document).ready(function() {
$('#checkEmail').click(function() {
var name = $('#Email').val();
var data = 'validateEmail=' + name;
$.ajax({
type: "GET",
url: "ValidateCandidate",
data: data,
success: function (data) {
alert(data);
}
});
return false;
});
});
</script>
HTML代碼
<%: Html.TextBox("Email",Model.Email, new {@title="Enter the Candidate Email Id"})%>
<a id="checkEmail" href="#" ></a> | <a id="getCandidate"></a>
在當我鍵入電子郵件ID在文本框它觸發電子郵件ID被註冊或不上面的代碼。然後我再給出一個鏈接getdetails。如果我點擊該鏈接,那麼該配置文件將通過使用鏈接GetCandidateDetail?validateEmail=' + $('#Email').val())
來。
但現在我想當我在文本框中鍵入電子郵件ID,如果存在意味着它會自動加載鏈接GetCandidateDetail?validateEmail=' + $('#Email').val())
否則爲false。這個怎麼做?幫我解決這個問題?
你應該把你所有的代碼放入就緒函數。在完全加載之前,您不能使用DOM元素。 – Hardy
也加上你的html .. – Hardy
k我更新我的問題..請參見 – PoliDev