请帮助我,我正在尝试使用javascript创建注册表单并进行解析,但无法提交此处是我的代码
<html>
<script type="text/javascript" src="https://npmcdn.com/parse/dist/parse.min.js"></script>
<form>
<div class="container">
<h1>Register</h1>
<p>Please fill in this form to create an account.</p>
<hr>
<label for="username"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="username" id="username" required>
<br>
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name="email" id="email" required>
<br>
<label for="age"><b>Age</b></label>
<input type="text" placeholder="Enter Your Age" name="age" id="age" required>
<br>
<label for="password"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password" id="password" required>
<br>
<label for="psw-repeat"><b>Repeat Password</b></label>
<input type="password" placeholder="Repeat Password" name="psw-repeat" required>
<hr>
<p>By creating an account you agree to our <a href="#">Terms & Privacy</a>.</p>
<button onclick="test()" class="registerbtn">Register</button>
</div>
<div class="container signin">
<p>Already have an account? <a href="#">Sign in</a>.</p>
</div>
</form>
<script type="text/javascript">
Parse.initialize(
"XXXX",
"YYYY"
);
Parse.serverURL = 'ZZZZ';
var user = new Parse.User();
user.save({
username: document.getElementById("username").value,
email: document.getElementById("email").value,
password: document.getElementById("password").value
}).then(function(response) {
alert('New object create with success! ObjectId: ' + response.id + ', '+ user.get('username'));
}).catch(function(error) {
alert('Error: ' + error.message);
});
}
</script>
</html>
我尝试将解析用户注册查询放入一个函数中并在Submit上运行,但这也不起作用。
我知道它不是服务器错误,因为我可以删除表格并直接设置用户名,密码等,这是可行的。
有人知道我如何进行这项工作吗?
我认为问题主要出在用户单击“提交”时从表单获取字段,但是我不知道该怎么做,请帮忙。
谢谢:)