1
I’m validating the registered user’s email, and I want to display the message to him if the email already exists, so I did so:
//validação de email
$(function validateEmail() {
$('#Email').change(function () {
var url = '@Url.Action("ValidateEmail", "Ajax")';//url do controller que passará a informação
var email = $('#Email').val();
$.ajax({
type: 'POST',
url: url,
data: { email: email },
dataType: 'json',
success: function (data) {
$('#MensagemEmail').append("Email Já Cadastrado");
$('#Email').focus();
},
error: function (data) {
$('#MensagemEmail').append("Email Disponível");
}
});
});
});//Fim da validação de email
my problem is that when the user inserts 2 emails that already have, the message is duplicated as shown in the image below:
my question is how do I clear the value before inserting another? because I tried to use $('#MensagemEmail').val('');
but it did not happen.
Thank you @lucascosta
– Fabio Souza