Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未捕获类型错误:无法读取属性';价值';在HTMLInputElement.onclick的signUpValidate(fhe.js:26)处为null_Javascript_Html - Fatal编程技术网

Javascript 未捕获类型错误:无法读取属性';价值';在HTMLInputElement.onclick的signUpValidate(fhe.js:26)处为null

Javascript 未捕获类型错误:无法读取属性';价值';在HTMLInputElement.onclick的signUpValidate(fhe.js:26)处为null,javascript,html,Javascript,Html,我正在尝试让用户输入他们的注册信息。我遇到了一个错误,看起来我知道错误是什么,但我不知道如何修复它。请找人帮忙 未捕获的TypeError:无法在HTMLInputElement.onclick的signUpValidate(fhe.js:26)处读取null的属性“value” HTML代码: <!DOCTYPE html> <html lang="en">`enter code here` <head> <script type="text/

我正在尝试让用户输入他们的注册信息。我遇到了一个错误,看起来我知道错误是什么,但我不知道如何修复它。请找人帮忙

未捕获的TypeError:无法在HTMLInputElement.onclick的signUpValidate(fhe.js:26)处读取null的属性“value”

HTML代码:

<!DOCTYPE html>
<html lang="en">`enter code here`
<head>
    <script type="text/javascript" src="fhe.js"></script>
    <link rel="stylesheet" href="fheCss.css"/>
    <meta charset="UTF-8">
    <title>Sign Up Page</title>
    <h1>Family Home Evening</h1>
    <h3>Sign Up</h3>
</head>
<body class="backgroundPic">
<form class="mySignUpForm">
    <input type="text" placeholder="First Name" name="firstName" required/><br><br>
    <input type="text" placeholder="Last Name" name="lastName" required/><br><br>
    <input type="text" placeholder="Username" name="signUpUserName" pattern="^[a-zA-Z][a-zA-Z0-9-_\.]{8,20}$" required/><br><br>
    <input type="text" placeholder="Password" name="signUpPassword" pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" required/><br><br>
    <input type="text" placeholder="Verify Password" name="signUpVerPassword" pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" required/><br><br>

    <input type="button" value="Sign up" id="signup" onclick="signUpValidate()"/><br><br>
    <a href="login.html">Back to Login</a><br><br>
</form>

<h4>Username: Username must be between 8 to 20 character<br><br>
    Password: Password must contain 1 uppercase, lowercase and number</h4><br><br>
</body>
</html>

您正在使用
document.getElementById
获取元素,但您尚未在元素本身(在HTML中)上定义ID。请注意,元素的名称与其ID不同。

您正在使用
document.getElementById
获取元素,但您尚未在元素本身(在HTML中)上定义ID。请注意,元素的名称与其ID不同。

您正在使用
document.getElementById()
从表单中获取值,但您没有在输入元素中提供
ID
属性

<input type="text" id="firstName" placeholder="First Name" name="firstName" required/><br><br>
<input type="text" id="lastName" placeholder="Last Name" name="lastName" required/><br><br>
<input type="text" id="signUpUserName" placeholder="Username" name="signUpUserName" pattern="^[a-zA-Z][a-zA-Z0-9-_\.]{8,20}$" required/><br><br>
<input type="text" id="signUpPassword" placeholder="Password" name="signUpPassword" pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" required/><br><br>
<input type="text" id="signUpVerPassword" placeholder="Verify Password" name="signUpVerPassword" pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" required/><br><br>











您正在使用
document.getElementById()
从表单中获取值,但是您没有在输入元素中提供
id
属性

<input type="text" id="firstName" placeholder="First Name" name="firstName" required/><br><br>
<input type="text" id="lastName" placeholder="Last Name" name="lastName" required/><br><br>
<input type="text" id="signUpUserName" placeholder="Username" name="signUpUserName" pattern="^[a-zA-Z][a-zA-Z0-9-_\.]{8,20}$" required/><br><br>
<input type="text" id="signUpPassword" placeholder="Password" name="signUpPassword" pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" required/><br><br>
<input type="text" id="signUpVerPassword" placeholder="Verify Password" name="signUpVerPassword" pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" required/><br><br>











问题是,您正在尝试获取
getElementById
,但没有具有该ID的元素,因此需要在所有试图获取数据的输入字段上添加ID

<!DOCTYPE html>
<html lang="en">`enter code here`
<head>
    <script type="text/javascript" src="fhe.js"></script>
    <link rel="stylesheet" href="fheCss.css"/>
    <meta charset="UTF-8">
    <title>Sign Up Page</title>
    <h1>Family Home Evening</h1>
    <h3>Sign Up</h3>
</head>
<body class="backgroundPic">
<form class="mySignUpForm">
    <input type="text" placeholder="First Name" name="firstName"  id="firstName" required/><br><br>
    <input type="text" placeholder="Last Name" name="lastName" id="lastName" required/><br><br>
    <input type="text" placeholder="Username" name="signUpUserName" id="signUpPassword" pattern="^[a-zA-Z][a-zA-Z0-9-_\.]{8,20}$" required/><br><br>
    <input type="text" placeholder="Password" name="signUpPassword" id="signUpPassword" pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" required/><br><br>
    <input type="text" placeholder="Verify Password" name="signUpVerPassword" id="signUpVerPassword" pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" required/><br><br>

    <input type="button" value="Sign up" id="signup" onclick="signUpValidate()"/><br><br>
    <a href="login.html">Back to Login</a><br><br>
</form>

<h4>Username: Username must be between 8 to 20 character<br><br>
    Password: Password must contain 1 uppercase, lowercase and number</h4><br><br>
</body>
</html>

`在这里输入代码`
注册页面
家庭之夜
注册














用户名:用户名必须在8到20个字符之间

密码:密码必须包含1个大写、小写和数字


问题是,您正在尝试获取
getElementById
,但没有具有该ID的元素,因此需要在所有试图获取数据的输入字段上添加ID

<!DOCTYPE html>
<html lang="en">`enter code here`
<head>
    <script type="text/javascript" src="fhe.js"></script>
    <link rel="stylesheet" href="fheCss.css"/>
    <meta charset="UTF-8">
    <title>Sign Up Page</title>
    <h1>Family Home Evening</h1>
    <h3>Sign Up</h3>
</head>
<body class="backgroundPic">
<form class="mySignUpForm">
    <input type="text" placeholder="First Name" name="firstName"  id="firstName" required/><br><br>
    <input type="text" placeholder="Last Name" name="lastName" id="lastName" required/><br><br>
    <input type="text" placeholder="Username" name="signUpUserName" id="signUpPassword" pattern="^[a-zA-Z][a-zA-Z0-9-_\.]{8,20}$" required/><br><br>
    <input type="text" placeholder="Password" name="signUpPassword" id="signUpPassword" pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" required/><br><br>
    <input type="text" placeholder="Verify Password" name="signUpVerPassword" id="signUpVerPassword" pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" required/><br><br>

    <input type="button" value="Sign up" id="signup" onclick="signUpValidate()"/><br><br>
    <a href="login.html">Back to Login</a><br><br>
</form>

<h4>Username: Username must be between 8 to 20 character<br><br>
    Password: Password must contain 1 uppercase, lowercase and number</h4><br><br>
</body>
</html>

`在这里输入代码`
注册页面
家庭之夜
注册














用户名:用户名必须在8到20个字符之间

密码:密码必须包含1个大写、小写和数字


输入元素中没有id字段,但您使用document.getElementById获取DOM值。。为firstName字段添加field id=“firstName”,并将相应的id字段添加到其他输入您在输入元素中没有id字段,但您使用document.getElementById获取DOM值。。为firstName字段添加field id=“firstName”,并将相应的id字段添加到其他inputsOh ya中,从而修复了该字段。谢谢:)哦,是的,这就解决了。谢谢:)