One solution you can do is check as the autocomplete fills out. This is some sample code for filling out my text field.
$("#search").autocomplete({
source: function (request, response) {
$.ajax({
url: "MyWebService.asmx/FetchUsers",
data: "{ 'search': '" + request.term + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) { return data; },
success: function (data) {
response($.map(data.d, function (item) {
return {
value: item
}
}))
},
error: AjaxFailed
});
},
minLength: 3
});
So you can change the success to look like
success: function (data) {
if (data.d.length == 0)
alert('Does Not Exist');
else {
response($.map(data.d, function (item) {
return {
value: item
}
})) }
}
If you want to do it as they hit the click button, you can create a button and tie a javascript function to the onClick event to do a post to a webservice and check if the value exists so it'd be something along the lines of this:
<asp:Button ID="Button1" runat="server" onclick="verifyFriendExists()"></asp:Button>
<script type="text/javascript">
function verifyFriendExists() {
var user = $('#userbox').value;
$.ajax({
type: "POST",
url: "MyWebService.asmx/VerifyParticipant",
data: "{'user': '" + user + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d != "Success")
alert('Does Not Exist');
},
error: AjaxFailed
});
}
</script>
And create a WebService with a method that's something like
[WebMethod]
public String VerifyParticipant(string user)
{
bool userExists = CheckParticipant(user);
if (userExists)
return "Success";
else
return "Does Not Exist";
}
I know that's a lot to look over. Let me know if I wasn't clear on something. Good luck!