Commit f6d13942 by Teeradone Darunnat

teeradone validate register

parent 27609774
......@@ -95,8 +95,8 @@
<?php echo $this->Html->script('/js/magnific-popup/jquery.magnific-popup.min'); ?>
<?php echo $this->Html->script('/js/vide/vide.min'); ?>
<?php echo $this->Html->script('/js/validate/jQuery.start.min'); ?>
<?php echo $this->Html->script('/js/validate/jQuery.validate.addValidate'); ?>
<?php echo $this->Html->script('/js/validate/jQuery.validate.min'); ?>
<?php echo $this->Html->script('/js/validate/jQuery.validate.addValidate'); ?>
<!-- Theme Base, Components and Settings -->
<?php echo $this->Html->script('theme'); ?>
<!-- Theme Custom -->
......
......@@ -11,7 +11,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('Firstname');?><em>* </em></label>
<input type="text" name="firstname" id="firstname" value="" placeholder="FIRSTNAME" class="form-control-reg border-bottom-from required letters">
<input type="text" name="firstname" id="firstname" value="" placeholder="FIRSTNAME" class="form-control-reg border-bottom-from required letterthai">
</div>
</div>
......@@ -20,7 +20,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('Lastname');?><em>* </em></label>
<input type="text" name="lastname" id="lastname" value="" placeholder="LASTNAME" class="form-control-reg border-bottom-from required">
<input type="text" name="lastname" id="lastname" value="" placeholder="LASTNAME" class="form-control-reg border-bottom-from required letterthai">
</div>
</div>
......@@ -82,7 +82,7 @@
<div class="form-group has-feedback bootstrap-iso">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('Birthdate');?></label>
<input type="text" name="birthdate" id="date" placeholder="กรุณาระบุวันเดือนปีเกิด" value="" placeholder="DD-MM-YYYY" data-date-format="mm/dd/yyyy" class="form-control-reg border-bottom-from required datepicker" readonly>
<input type="text" name="birthdate" id="date" placeholder="กรุณาระบุวันเดือนปีเกิด" value="" placeholder="DD-MM-YYYY" data-date-format="mm/dd/yyyy" class="form-control-reg border-bottom-from required date" readonly>
<span class="glyphicon glyphicon-calendar form-control-feedback"></span>
</div>
</div>
......@@ -100,7 +100,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('Email');?><em>* </em></label>
<input type="text" name="email" id="fremail" value="" placeholder="mail@xxx.com" class="form-control-reg border-bottom-from required email small_letters">
<input type="text" name="email" id="fremail" value="" placeholder="mail@xxx.com" class="form-control-reg border-bottom-from required email emailtext">
</div>
</div>
......@@ -109,7 +109,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('Password');?><em>* </em></label>
<input data-toggle="password" data-placement="before" type="password" name="password" id="password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from required" style="padding:0px 0px !important;" minlength=8>
<input data-toggle="password" data-placement="before" type="password" name="password" id="password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from required alphanumeric" style="padding:0px 0px !important;" minlength=8>
<!--<input type="password" name="data[password]" id="password" value="" placeholder="********" class="form-control-reg border-bottom-from" onkeyup='check();'>-->
<!--<span class="glyphicon glyphicon-eye-close form-control-feedback"></span>-->
</div>
......@@ -119,7 +119,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('Confirm password');?><em>* </em></label>
<input data-toggle="password" data-placement="before" type="password" name="confirm_password" id="confirm_password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from required" style="padding:0px 0px !important;" minlength=8>
<input data-toggle="password" data-placement="before" type="password" name="confirm_password" id="confirm_password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from required alphanumeric" style="padding:0px 0px !important;" minlength=8>
<!--<input type="password" id="confirm_password" name="data[confirm_password]" value="" placeholder="********" class="form-control-reg border-bottom-from" onkeyup='check();'>-->
<!--<span class="glyphicon glyphicon-eye-close form-control-feedback" id='message'></span>-->
<span id='message'></span>
......@@ -166,84 +166,6 @@
<!-- ------------------------------- popup ----------------------------------- -->
<script>
$(document).ready(function() {
$("#username").on('change',function(){
var elem = document.getElementById('username').value;
// console.log(elem);
if(!elem.match(/^([A-Za-z0-9])+$/i)){
alert("<?php echo __('Please enter only text in English or numbers.');?>");
return false;
}
})
$("#firstname").on('change',function(){
var elem = document.getElementById('firstname').value;
// console.log(elem);
if(!elem.match(/^([A-Za-z0-9ก-๙])+$/i)){
alert("<?php echo __('Please enter text in English, Thai or only.');?>");
return false;
}
})
$("#lastname").on('change',function(){
var elem = document.getElementById('lastname').value;
// console.log(elem);
if(!elem.match(/^([A-Za-z0-9ก-๙])+$/i)){
alert("<?php echo __('Please enter text in English, Thai or only.');?>");
return false;
}
})
$("#password").on('change',function(){
var elem = document.getElementById('password').value;
// console.log(elem);
if(!elem.match(/^([A-Za-z0-9])+$/i)){
alert("<?php echo __('Please enter only text in English or numbers.');?>");
return false;
}
})
$("#confirm_password").on('change',function(){
var elem = document.getElementById('confirm_password').value;
// console.log(elem);
if(!elem.match(/^([A-Za-z0-9])+$/i)){
alert("<?php echo __('Please enter only text in English or numbers.');?>");
return false;
}
})
$("#fremail").on('change',function(){
var elem = document.getElementById('fremail').value;
console.log(elem);
if(!elem.match(/^([A-Za-z0-9@._])+$/i)){
alert("<?php echo __('Wrong email address format Please enter the correct number.');?>");
return false;
}
})
$("#fremail").on('change',function(){
var email = document.getElementById("fremail").value;
$.post("/Checkemails/checkemail", {email: email}, function(data) {
// console.log(data);
data = jQuery.parseJSON(data);
if(data['chk'] == 'false'){
alert("<?php echo __('This email is already in the system.');?>");
return false;
}
});
});
});
// function check_phone() {
// e_k=event.keyCode
// // if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
// if (e_k = 10 && (e_k < 48) || (e_k > 59)) {
// event.returnValue = false;
// alert("<?php echo __('Please enter the phone number. Only numbers.');?>");
// }
// }
function validateForm() {
var password = document.getElementById("password").value;
var confirm_password = document.getElementById("confirm_password").value;
......
......@@ -26,6 +26,15 @@
| 19. ckquarter-min ,Example 'ckquarter-min' = '2'
| ------------------------------------------------------------------------------------------------------------------
*/
jQuery.validator.addMethod("emailtext", function (value, element) {
return this.optional(element) || /^([a-zA-Z@_.])+$/.test(value);
}, "โปรดระบุที่อยู่อีเมล์ที่ถูกต้อง.");
jQuery.validator.addMethod("letterthai", function (value, element) {
return this.optional(element) || /^([a-zA-Zก-๙])+$/.test(value);
}, "เฉพาะตัวอักษรเท่านั้น.");
jQuery.validator.addMethod("letterthai", function (value, element) {
return this.optional(element) || /^([a-zA-Zก-๙])+$/.test(value);
}, "เฉพาะตัวอักษรเท่านั้น.");
jQuery.validator.addMethod("letters", function (value, element) {
return this.optional(element) || /^[a-zA-Z]+$/i.test(value);
}, "เฉพาะตัวอักษรเท่านั้น.");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment