Javascript Jquery表单值确认
有人能告诉我为什么这是假的吗?我正在使用jquerymobile构建一个Cordova应用程序,试图为我的用户身份验证系统使用类似的代码,以确保密码和密码确认是相同的。然后,这些数据将被发送到我的服务器上的一个php文件,然后根据那里的验证,php将返回“成功”或“失败”。因此,我的另一个问题是,如何根据php文件返回的结果在应用程序上更改视图?如果有人能给我推荐一个做这件事的好方法或者一个我可以学习的教程,那就太好了,因为我找不到关于这件事的好教程,因为我对这一切都不熟悉Javascript Jquery表单值确认,javascript,php,jquery,cordova,validation,Javascript,Php,Jquery,Cordova,Validation,有人能告诉我为什么这是假的吗?我正在使用jquerymobile构建一个Cordova应用程序,试图为我的用户身份验证系统使用类似的代码,以确保密码和密码确认是相同的。然后,这些数据将被发送到我的服务器上的一个php文件,然后根据那里的验证,php将返回“成功”或“失败”。因此,我的另一个问题是,如何根据php文件返回的结果在应用程序上更改视图?如果有人能给我推荐一个做这件事的好方法或者一个我可以学习的教程,那就太好了,因为我找不到关于这件事的好教程,因为我对这一切都不熟悉 $(document
$(document).on('pagebeforeshow', '#signuppage', function () {
$(document).on('click', '#signupbutton', function () {
if ($('#confirmpassword').val() === $('#password').val()) {
$.ajax({
url: 'http://localhost/appAuth/profiling.php',
data: {
action: 'signup',
formData: $('#signupform').serialize()
},
type:'post',
async: true,
dataType: 'json',
beforeSend: function () {
//this is the callback function will trigger before data is sent
$.mobile.showPageLoadingMsg(true);
},
complete: function () {
//this is the callback functino will trigger on data sent/received complete
$.mobile.hidePageLoadingMsg();
},
success: function (result) {
resultObject.formSubmitionResult = result;
$mobile.changePage("#collections");
},
error: function (request, error) {
//this is the callback function will trigger on unsuccessful action
alert('Network error has occured please try again!');
}
});
}
else
{
alert('Please make sure the two passwords match!');
}
return false; //cancel original event to prevent form submitting
});
});
以下是所需的HTML:
<div data-role="page" id="signuppage" style="background-color:#454545;">
<div data-role="header" id="head">
<h1>
<a href="#" class="ui-btn ui-btn-left ui-corner-all ui-shadow ui-btn-inline ui-icon-back ui-btn-icon-left" data-rel="back">Back</a>
<strong>Signup</strong>
</h1>
</div>
<div data-role="main" class="ui-content">
<form id="signupform" data-ajax="false">
<fieldset data-role="fieldcontain">
<label for="firstname">First name:</label>
<input type="text" name="firstname" id="firstname" placeholder="Enter First Name" required>
</fieldset>
<fieldset data-role="fieldcontain">
<label for="lastname">Last name:</label>
<input type="text" name="lastname" id="lastname" placeholder="Enter Last Name" required>
</fieldset>
<fieldset data-role="fieldcontain">
<label for="email">Email:</label>
<input type="email" name="email" id="email" placeholder="Your Email..." required email>
</fieldset>
<fieldset data-role="fieldcontain">
<label for="username">Username:</label>
<input type="text" name="username" id="username" placeholder="Enter Username" required>
</fieldset>
<fieldset data-role="fieldcontain">
<label for="password">Password:</label>
<input type="password" name="password" id="password" placeholder="Enter Password" required>
</fieldset>
<fieldset data-role="fieldcontain">
<label for="confirmpassword">Confirm password:</label>
<input type="password" name="confirmpassword" id="confirmpassword" placeholder="Confirm password" required equalTo="password">
</fieldset>
<input type="submit" data-inline="true" value="Submit" name="signupbutton" id="signupbutton">
</form>
</div>
</div>
注册
名字:
姓氏:
电邮:
用户名:
密码:
确认密码:
?可能是因为Firstname
=/=Lastname
如果您在两个字段中输入相同的数据,它将返回TRUEWell您最好也向我们显示HTML,或者此Javascript对USCA来说意义不大。您可以解释一下您的意思;“我可以在应用程序上更改我的视图”。完成Ajax请求后,您想更改什么,那么你希望发生什么呢?所以我想创建一个系统,如果用户没有登录,如果他碰巧点击了一个按钮,他将被自动引导到登录页面,成功登录后,他将被重定向回按钮将带他登录的位置,同时,如果他没有登录他会注册一个账户,然后再转到同一页。