now I"m going to write a registration page. What"s the difference between submitting a form form and directly fetching the vlaue value of input? It turns out that login and registration pages have always been done by taking values directly;
< H1 > or if there is something wrong with the writing below, please give me some advice < / H1 >form form
<form id="form">
<div>
<label for="username">:</label>
<input type="text" name="username" required="required" placeholder="" id="username">
</div>
<div>
<label for="mobile">:</label>
<input type="text" name="mobile" required="required" placeholder=":" id="mobile">
</div>
<div>
<label for="password">:</label>
<input type="password" name="password" required="required" placeholder="" id="password">
</div>
<input type="submit" value="" class="btn">
</form>
//js
form = $("-sharpform");
form.data().submit = function (){
form.data() = $.post(url,{
username:form.data().username,
mobile: form.data().mobile,
})
}
Direct value method
<input type="text" name="username" required="required" placeholder="" id="username">
<input type="text" name="mobile" required="required" placeholder=":" id="mobile">
//js
var username = $("username").val();
var mobile= $("mobile").val();
$.post(url,{
username:username,
mobile:mobile
});
what are the advantages and disadvantages of these two ways? Forget about form validation