Skip to content
Snippets Groups Projects
Commit 81f9d6f5 authored by Yulong Wang's avatar Yulong Wang
Browse files

Delete emailValidation.js

parent 3dfa745c
No related branches found
No related tags found
No related merge requests found
$(document).ready(function () {
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; // 简单 Email 正则
//Listen for input events using jQuery's on method
$('#email').on('input', function () {
const emailValue = $(this).val();
const $emailError = $('#emailError');
// Check whether the input is empty or does not match the regular expression
if (!emailPattern.test(emailValue) && emailValue !== '') {
$emailError.text("Please enter a valid email address.");
$emailError.show(); // Display error message
} else {
$emailError.text("");
$emailError.hide(); // Hide error message
}
});
$('#name').on('mouseleave', function () {
const value = $(this).val();
const $nameError = $('#nameError');
if (value == '') {
$nameError.text("Please enter data.");
$nameError.show();
} else {
$nameError.text("");
$nameError.hide();
}
});
$('#password').on('mouseleave', function () {
const value = $(this).val();
const $passwordError= $('#passwordError');
if (value == '') {
$passwordError.text("Please enter data.");
$passwordError.show();
} else {
$passwordError.text("");
$passwordError.hide();
}
});
$('#phone').on('mouseleave', function () {
const value = $(this).val();
const $phoneError= $('#phoneError');
// 检查输入是否为空或不符合正则表达式
if (value == '') {
$phoneError.text("Please enter data.");
$phoneError.show();
} else {
$phoneError.text("");
$phoneError.hide();
}
});
$('#address').on('mouseleave', function () {
const value = $(this).val();
const $addressError= $('#addressError');
if (value == '') {
$addressError.text("Please enter data.");
$addressError.show();
} else {
$addressError.text("");
$addressError.hide();
}
});
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment