As I work on developing a web application, I am faced with the challenge of checking for duplicate email addresses in real-time without the need to press a button. This check must be done by comparing the data with information stored in the database. Since I am new to JavaScript, I could use some guidance on this matter.
Big shoutout to @Scandinave for offering assistance. However, I encountered an issue where the text entered into the textbox did not trigger the method in the code file. Here is the approach I attempted:
$(document).ready(function () {
// Listen for change event
$("input[name='TextBox1']").keyup(function () {
// Get input fields values
var $email1 = $("input[name='TextBox1']").val();
// Make an AJAX request
$.ajax({
method: "POST",
url: "Default.aspx.cs/test",
data: { email1: $email1 }
}).done(function (msg) {
// Check the JSON result sent from the backend
if (msg === "true") {
console.log("Emails are identical");
}
});
});
});