Tôi đang tìm cách tạo thông báo lỗi xác thực biểu mẫu đơn giản hiển thị trong trường tên người dùng.javascript cách tạo thông báo lỗi xác thực mà không sử dụng cảnh báo
Tôi dường như không thể tìm ra.
<form name ="myform" onsubmit="validation()">
Username: <input type ="text" name="username" /><br />
<input type ="submit" value="submit" />
<div id ="errors">
</div>
</form>
Đây là kịch bản xác nhận của tôi:
function validation(){
if(document.myform.username.value == ""){ //checking if the form is empty
document.getElementById('errors').innerHTML="*Please enter a username*";
//displaying a message if the form is empty
}
gì đang xảy ra vậy? Có vẻ như nó sẽ hiển thị tin nhắn ... – Xymostech