|
|
|
อยากทราบเรื่อง checktext กับ comfirmpassword สามารถอยู่ในโค๊ดชุดเดียวกันได้หรือไม่ |
|
|
|
|
|
|
|
คือมันสามารถเช็คได้ทั้งหมดเลยใช้ไหมครับ
|
|
|
|
|
Date :
2017-12-27 22:27:06 |
By :
aunpun01 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองแล้วนะฮะไม่เช็คค่าอะไรเลย +-+ งงมาก
รบกวนด้วยครับพอดีผมจะทักค่าวางในการRegister แล้วถ้าอันไหนที่มีค่าวางให้ดักก่อนทำการกด button แต่ทีนี้javascriptผมดันไม่ดักค่าให้ และไม่เช็ค comfirmpassword ผมเขียนผิดตรงไหนหรอครับ ปล.ทำมา3-4วันแล้ว ยังไม่รอด
Code (XML)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>index</title>
<style media="screen">
@media(min-width: 768px) {
.field-label-responsive {
padding-top: .5rem;
text-align: right;
}
}
</style>
<!--libary_css-->
<?php include('includes/libary_css.php') ?>
<!--navbar -->
<?php include('includes/navbar.php')?>
</head>
<body>
<script language="javascript">
function fncSubmit()
{
if(document.form.Username.value == "")
{
alert('Please input Username');
document.form.Username.focus();
return false;
}
if(document.form.password.value == "")
{
alert('Please input Password');
document.form.password.focus();
return false;
}
if(document.form.Cfpass.value == "")
{
alert('Please input Confirm Password');
document.form.Cfpass.focus();
return false;
}
if(document.form.password.value != document.form.Cfpassword.value)
{
alert('Confirm Password Not Match');
document.form.Cfpass.focus();
return false;
}
if(document.form.Firstname.value == "")
{
alert('Please input Name');
document.form.Firstname.focus();
return false;
}
if(document.form.lastname.value == "")
{
alert('Please input Name');
document.form.lastname.focus();
return false;
}
if(document.form.email.value == "")
{
alert('Please input Name');
document.form.email.focus();
return false;
}
if(document.form.phone.value == "")
{
alert('Please input Name');
document.form.phone.focus();
return false;
}
document.form.register();
}
</script>
<div class="jumbotron">
<title>Register</title>
<div class="container">
<form class="form-horizontal" role="form" name="form" method="POST" OnSubmit="return fncSubmit();" action="">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<h2>Register New User</h2>
<hr>
</div>
</div>
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for="Username">username</label>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-user"></i></div>
<input type="text" name="Username" class="form-control" id="Username" placeholder="Pless Username">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for="Firstname">Firstname</label>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-user"></i></div>
<input type="text" name="Firstname" class="form-control" id="Firstname" placeholder="....">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for="lastname">Lastname</label>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-user"></i></div>
<input type="text" name="lastname" class="form-control" id="lastname" placeholder="....">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for="phone">Telephone number</label>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-user"></i></div>
<input type="text" name="phone" maxlength="10" class="form-control" id="phone" placeholder="Pless Telephone" onKeyUp="if(this.value*1!=this.value) this.value='' ;">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for="email">Email</label>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-at"></i></div>
<input type="email" name="email" class="form-control" id="email" placeholder="pless email">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for1="password">Password</label>
</div>
<div class="col-md-6">
<div class="form-group has-danger">
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-key"></i></div>
<input type="password" name="password" class="form-control" id="password" placeholder="Password" required>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for="Cfpass">Confirm Password</label>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon" style="width: 2.6rem">
<i class="fa fa-repeat"></i>
</div>
<input type="password" name="Cfpass" class="form-control" id="Cfpass" placeholder="Password" required>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<button type="submit" class="btn btn-success" name="register"><i class="fa fa-user-plus"></i> Register</button>
</div>
</div>
</form>
</div>
<!--libary_scr-->
<?php include('includes/libary_scr.php')?>
</body>
</html>
|
|
|
|
|
Date :
2017-12-28 01:31:10 |
By :
aunpun01 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
function checkPassword(str)
{
var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}$/;
return re.test(str);
}
function checkForm(form)
{
if(form.username.value == "") {
alert("Error: Username cannot be blank!");
form.username.focus();
return false;
}
re = /^\w+$/;
if(!re.test(form.username.value)) {
alert("Error: Username must contain only letters, numbers and underscores!");
form.username.focus();
return false;
}
if(form.pwd1.value != "" && form.pwd1.value == form.pwd2.value) {
if(!checkPassword(form.pwd1.value)) {
alert("The password you have entered is not valid!");
form.pwd1.focus();
return false;
}
} else {
alert("Error: Please check that you've entered and confirmed your password!");
form.pwd1.focus();
return false;
}
return true;
}
</script>
<form method="POST" action="..." onsubmit="return checkForm(this);">
<p>Username: <input type="text" name="username"></p>
<p>Password: <input type="password" name="pwd1"></p>
<p>Confirm Password: <input type="password" name="pwd2"></p>
<p><input type="submit"></p>
</form>
</body>
</html>
|
|
|
|
|
Date :
2017-12-28 08:28:49 |
By :
Hararock |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|