I have a <%: Html.TextBoxFor(model=>model.UserName)%>. Here I'm checking wheather user name is available or not. If it's not available then I need to clear the TextBox. I used the query $("#UserName").val("");. But after the event completion again the text box getting the value. Can anyone help me?
UPDATE: Additional Javascript code from comments:
function CheckAvailability() {
$.post("/WebTeamReleaseDB/CheckAvailability", {
Username: $("#UserName").val()
}, function(data) {
var myObject = eval('(' + data + ')');
var newid = myObject;
if (newid == 1) {
$("#usernamelookupresult").html("<font color='green'>Available :-D</font>")
} else {
$("#UserName").val("");
$("#usernamelookupresult").html("<font color='red'>Taken :-(</font>")
}
});
}
UserName?