|
|
|
ช่วยดูโค้ดให้หน่อยค่ะ ติดตรง javascript ตรง password เขียนยังไงให้มันสามารถผ่านเงื่อนไขไปได้ค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>ระบบจองห้องเรียน | เพิ่มผู้ใช้ระบบ</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/business-frontpage.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Start Bootstrap</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<a href="#">About</a>
</li>
<li>
<a href="#">Services</a>
</li>
<li>
<a href="#">Contact</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<style type="text/css">
.input-group-addon.primary {
color: rgb(255, 255, 255);
background-color: rgb(50, 118, 177);
border-color: rgb(40, 94, 142);
}
.input-group-addon.success {
color: rgb(255, 255, 255);
background-color: rgb(92, 184, 92);
border-color: rgb(76, 174, 76);
}
.input-group-addon.info {
color: rgb(255, 255, 255);
background-color: rgb(57, 179, 215);
border-color: rgb(38, 154, 188);
}
.input-group-addon.warning {
color: rgb(255, 255, 255);
background-color: rgb(240, 173, 78);
border-color: rgb(238, 162, 54);
}
.input-group-addon.danger {
color: rgb(255, 255, 255);
background-color: rgb(217, 83, 79);
border-color: rgb(212, 63, 58);
}
</style>
<script src="js/jquery-1.11.1.min.js"></script>
<!-- Image Background Page Header -->
<!-- Note: The background image is set within the business-casual.css file. -->
<header class="business-header">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h1 class="tagline">Business Name or Tagline</h1>
</div>
</div>
</div>
</header>
<!-- Page Content -->
<div class="container">
<hr>
<?php
include("../conn/connect_db_server.php");
?><div class="row">
<div class="col-sm-10" align="right">
</div>
<div class="col-sm-2" align="left">
ชื่อผู้ใช้ระบบ : ......
</div></div>
<div class="row">
<div class="col-sm-12">
<h2>เพิ่มผู้ใช้งานในระบบ</h2>
<form class="form-horizontal" id="contactForm" name="contactForm" method="post" action="add_admin.php" >
<div class="form-group">
<label for="validate-text">ชื่อตำแหน่ง</label>
<div class="input-group">
<input type="text" class="form-control" name="position" id="position" placeholder="กรุณากรอกตำแหน่งการทำงาน" required>
<span class="input-group-addon danger"><span class="glyphicon glyphicon-remove"></span>
</div></div>
<div class="form-group">
<label for="validate-text">ชื่อ-นามสกุล</label>
<div class="input-group">
<input type="text" class="form-control" name="Name_surename" id="Name_surename" placeholder="กรุณากรอกชื่อ-นามสกุล" required>
<span class="input-group-addon danger"><span class="glyphicon glyphicon-remove"></span></span>
</div>
</div>
<div class="form-group">
<label for="validate-select">สาขาวิชา</label>
<div class="input-group">
<select name="major_code" class="form-control" id="major_code" placeholder="กรุณาเลือกสาขาวิชา" required>
<option value=""><-- กรุณาเลือกสาขาวิชา --></option>
<?php
$strSQL = "SELECT * FROM db_major_sub ORDER BY major_id ASC";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?php echo $objResuut["major_code"];?>"><?php echo $objResuut["major_name"];?></option>
<?php
}
?>
</select>
<span class="input-group-addon danger"><span class="glyphicon glyphicon-remove"></span></span>
</div>
</div>
<div class="form-group">
<label for="validate-text">ชื่อผู้ใช้งาน (user)</label>
<div class="input-group">
<input type="text" class="form-control" name="username" id="username" placeholder="กรุณากรอกชื่อผู้ใช้งาน" required>
<span class="input-group-addon danger"><span class="glyphicon glyphicon-remove"></span></span>
</div>
</div>
<div class="form-group">
<label for="validate-text">รหัสผ่าน (Password)</label>
<div class="input-group">
<input type="password" class="form-control" name="password" id="password" placeholder="กรุณากรอกรหัสผ่าน" required>
<span class="input-group-addon danger"><span class="glyphicon glyphicon-remove"></span></span>
</div>
</div>
<div class="form-group">
<label for="validate-select">กำหนดสิทธิ์ผู้ใช้งาน</label>
<div class="radio">
<label>
<input type="radio" name="type" id="type" value="1" checked="checked"/>ผู้ดูแลระบบ (เจ้าหน้าที่)
</label><br>
<label>
<input type="radio" name="type" id="type" value="2" checked="checked"/>ผู้ใช้ระบบ (อาจารย์)
</label>
</div>
</div>
<input class="btn btn-success" type="submit" value="Submit" name="submit"> <input class="btn btn-danger" type="reset" name="reset" value="Reset" />
</form>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('.input-group input[required], .input-group textarea[required], .input-group select[required]').on('keyup change', function() {
var $form = $(this).closest('form'),
$group = $(this).closest('.input-group'),
$addon = $group.find('.input-group-addon'),
$icon = $addon.find('span'),
state = false;
if (!$group.data('validate')) {
state = $(this).val() ? true : false;
}else if ($group.data('validate') == "email") {
state = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test($(this).val())
}else if($group.data('validate') == 'phone') {
state = /^[(]{0,1}[0-9]{3}[)]{0,1}[-\s\.]{0,1}[0-9]{3}[-\s\.]{0,1}[0-9]{4}$/.test($(this).val())
}else if ($group.data('validate') == "length") {
state = $(this).val().length >= $group.data('length') ? true : false;
}else if ($group.data('validate') == "number") {
state = !isNaN(parseFloat($(this).val())) && isFinite($(this).val());
}
if (state) {
$addon.removeClass('danger');
$addon.addClass('success');
$icon.attr('class', 'glyphicon glyphicon-ok');
}else{
$addon.removeClass('success');
$addon.addClass('danger');
$icon.attr('class', 'glyphicon glyphicon-remove');
}
if ($form.find('.input-group-addon.danger').length == 0) {
$form.find('[type="submit"]').prop('disabled', false);
}else{
$form.find('[type="submit"]').prop('disabled', true);
}
});
$('.input-group input[required], .input-group textarea[required], .input-group select[required]').trigger('change');
});
</script>
</div>
<!-- /.row -->
<!-- /.row -->
<hr>
<!-- Footer -->
<footer>
<div class="row">
<div class="col-lg-12">
<p>Copyright © Your Website 2014 Design By Korrakit</p>
</div>
</div>
<!-- /.row -->
</footer>
</div>
<!-- /.container -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
Tag : PHP, MySQL, JavaScript
|
|
|
|
|
|
Date :
2015-01-26 14:46:49 |
By :
gungging302 |
View :
801 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ย้าย Script ไปไว้หลังจาก โหลด jQuery แล้ว
Code
Code (JavaScript)
<script src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.input-group input[required], .input-group textarea[required], .input-group select[required]').on('keyup change', function() {
var $form = $(this).closest('form'),
$group = $(this).closest('.input-group'),
$addon = $group.find('.input-group-addon'),
$icon = $addon.find('span'),
state = false;
if (!$group.data('validate')) {
state = $(this).val() ? true : false;
}else if ($group.data('validate') == "email") {
state = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test($(this).val())
}else if($group.data('validate') == 'phone') {
state = /^[(]{0,1}[0-9]{3}[)]{0,1}[-\s\.]{0,1}[0-9]{3}[-\s\.]{0,1}[0-9]{4}$/.test($(this).val())
}else if ($group.data('validate') == "length") {
state = $(this).val().length >= $group.data('length') ? true : false;
}else if ($group.data('validate') == "number") {
state = !isNaN(parseFloat($(this).val())) && isFinite($(this).val());
}
if (state) {
$addon.removeClass('danger');
$addon.addClass('success');
$icon.attr('class', 'glyphicon glyphicon-ok');
}else{
$addon.removeClass('success');
$addon.addClass('danger');
$icon.attr('class', 'glyphicon glyphicon-remove');
}
if ($form.find('.input-group-addon.danger').length == 0) {
$form.find('[type="submit"]').prop('disabled', false);
}else{
$form.find('[type="submit"]').prop('disabled', true);
}
});
$('.input-group input[required], .input-group textarea[required], .input-group select[required]').trigger('change');
});
</script>
|
|
|
|
|
Date :
2015-01-26 19:08:54 |
By :
Krungsri |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|