我正在尝试创建一个表单来验证是否输入了电子邮件地址。不一定要检查其有效性,但基本上是 sakjfsfksldjf@email.com。我想知道如何在 PURE JavaScript 而没有 RegEx 中进行操作。
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Test File</title>
</head>
<script>
function submitForms() {
email_format = document.getElementById('email_input') // want to return T or F
if (email_format) {
//print email successful
}
else {
//print error message
}
</script>
<body>
<form>
Email:
<input type ="email" id ="email_input" />
</form>
<button type = "button" onclick = "submitForms;"> Submit All!
</button>
</body>
</html>