Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
smart_core_connect
/
core-connect
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5e93d833
authored
May 16, 2018
by
Teeradone-PIM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teeradone: register
parent
2905751c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
346 additions
and
112 deletions
+346
-112
www/src/Controller/UsersController.php
+175
-30
www/src/Model/Table/UsersTable.php
+34
-34
www/src/Template/Users/signup.ctp
+137
-48
No files found.
www/src/Controller/UsersController.php
View file @
5e93d833
<?php
namespace
App\Controller
;
use
App\Controller\AppController
;
use
Cake\Auth\DefaultPasswordHasher
;
use
Cake\Core\Configure
;
use
Cake\Http\Client
;
use
Cake\Routing\Router
;
use
Cake\I18n\Time
;
use
Cake\Mailer\Email
;
use
Cake\Utility\Security
;
class
UsersController
extends
AppController
{
...
...
@@ -86,46 +89,178 @@ class UsersController extends AppController
public
function
signup
()
{
$this
->
loadModel
(
'MasterCountries'
);
$this
->
loadModel
(
'MasterProvinces'
);
$countries
=
$this
->
MasterCountries
->
find
(
'list'
,
[
'conditions'
=>
[
'is_used'
=>
true
,
'id'
=>
1
],
'keyField'
=>
'id'
,
'valueField'
=>
[
'country_name_th'
]
]
);
if
(
!
empty
(
$countries
))
$countries
=
$countries
->
toArray
();
$provinces
=
$this
->
MasterProvinces
->
find
(
'list'
,
[
'conditions'
=>
[
'is_used'
=>
true
,
'master_country_id'
=>
1
],
'keyField'
=>
'id'
,
'valueField'
=>
'province_name_th'
]
);
if
(
!
empty
(
$provinces
))
$provinces
=
$provinces
->
toArray
();
$this
->
set
(
compact
(
'provinces'
,
'countries'
));
$this
->
viewBuilder
()
->
layout
(
'blank'
);
}
// public function getProvince() {
// $this->autoRender = false;
// $this->loadModel('MasterProvinces');
// $states = array();
// pr($this->request->$data);die;
// if (isset($this->request['data']['id'])) {
// $states = $this->MasterProvinces->find('list', array(
// 'keyField' => 'id',
// 'valueField' => ['country_name_th'],
// 'conditions' => array(
// 'State.countries_id' => $this->request['data']['id']
// )
// ));
// }
// header('Content-Type: application/json');
// pr($states);die;
// echo json_encode($states);
// exit();
// }
#---------------------------------------------------------------------------------------------------
#Signup
public
function
createAccount
()
{
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$data
=
$this
->
request
->
data
();
$this
->
loadModel
(
'UserPersonals'
);
$users
=
$this
->
Users
->
newEntity
();
$user_personals
=
$this
->
UserPersonals
->
newEntity
();
if
(
$this
->
request
->
is
(
'post'
))
{
// $username_check = $this->MasterProvinces->find('all')->toArray();
// pr($username_check);die;
// pr($this->request->data);die;
$today
=
Time
::
now
();
$dateNow
=
$today
->
i18nFormat
(
'yyyy-MM-dd HH:mm:ss'
);
$hasher
=
new
DefaultPasswordHasher
();
$firstname
=
$this
->
request
->
data
[
'firstname'
];
// $phone_no = $this->request->data['phone_no'];
$lastname
=
$this
->
request
->
data
[
'lastname'
];
$master_country_id
=
$this
->
request
->
data
[
'master_country_id'
];
$master_province_id
=
$this
->
request
->
data
[
'master_province_id'
];
$password
=
$this
->
request
->
data
[
'password'
];
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
$btn
=
$this
->
request
->
data
[
'btn'
];
if
(
!
empty
(
$this
->
request
->
data
[
'birthdate'
])){
$birthdate
=
explode
(
"/"
,
$this
->
request
->
data
[
'birthdate'
]);
$birthdate
=
$birthdate
[
2
]
.
'-'
.
$birthdate
[
1
]
.
'-'
.
$birthdate
[
0
];
$this
->
request
->
data
[
'birthdate'
]
=
$birthdate
;
}
else
{
$birthdate
=
'2000-10-10'
;
}
if
(
!
empty
(
$data
)){
if
(
$this
->
validateAccount
(
$data
)){
$data
[
'data'
][
'ip'
]
=
$this
->
request
->
clientIp
();
#prr($data);
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$password
);
$users
[
'created_by'
]
=
0
;
$users
[
'is_used'
]
=
true
;
$users
[
'created'
]
=
$dateNow
;
$users
[
'dynamic_key'
]
=
'dynamic_key'
;
// $users['point'] = 0;
$users
[
'dynamic_key_expiry'
]
=
date
(
'Y-m-d'
,
strtotime
(
'+3 day'
));
$users
[
'token'
]
=
Security
::
hash
(
$this
->
request
->
data
[
'username'
]
.
date
(
'Y-m-d h:i:s'
),
'md5'
,
true
);
$users
[
'token_expiry'
]
=
date
(
'Y-m-d'
,
strtotime
(
'+3 day'
));
// $users['modified_by'] = $modified_by;
$digits
=
4
;
$users
[
'pin_code'
]
=
str_pad
(
rand
(
0
,
pow
(
10
,
$digits
)
-
1
),
$digits
,
'0'
,
STR_PAD_LEFT
);
if
(
!
empty
(
$this
->
request
->
data
[
'accept'
])){
$username_check
=
$this
->
Users
->
find
(
'all'
,[
'conditions'
=>
[
'Users.username'
=>
$this
->
request
->
data
[
'username'
]
]
])
->
toArray
();
$api_core_create_account
=
Configure
::
read
(
'Config.apiCore.createAccount'
);
$http
=
new
Client
();
$response
=
$http
->
post
(
$api_core_create_account
,
$data
)
->
body
();
#prd($response);
$response
=
json_decode
(
$response
,
'_full'
);
//debug($response);exit();
if
(
!
empty
(
$response
)){
if
(
trim
(
$response
[
'status'
])
==
'Success'
){
$this
->
Flash
->
success
(
__
(
'create Account completed.'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'pinCode/'
.
$response
[
'result'
][
'data'
][
'token'
]]);
}
elseif
(
$response
[
'result'
][
'message'
]
==
'Email Duplicate'
){
$this
->
Flash
->
error
(
__
(
'Email Duplicate'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'signup'
]);
}
else
{
$this
->
Flash
->
error
(
__
(
'create Account Fail'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'signup'
]);
$email_check
=
$this
->
UserPersonals
->
find
(
'all'
,[
'conditions'
=>
[
'UserPersonals.email'
=>
$this
->
request
->
data
[
'email'
]
]
])
->
toArray
();
if
((
empty
(
$username_check
))
&&
(
empty
(
$email_check
))){
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
// pr($users);die;
//------------------------------ ส่งอีเมล์ -----------------------------------------------------
// $data_notification = [];
// $data_notification['email'] = $this->request->data['email'];
// $data_notification['pin_code'] = $users['pin_code'];
// $this->notification($data_notification);
//----------------------------------------------------------------------------------------------
$this
->
Users
->
save
(
$users
);
$user_personals
[
'master_country_id'
]
=
$master_country_id
;
$user_personals
[
'master_province_id'
]
=
$master_province_id
;
$user_personals
[
'user_id'
]
=
$users
[
'id'
];
$user_personals
[
'firstname_th'
]
=
$firstname
;
$user_personals
[
'lastname_th'
]
=
$lastname
;
$user_personals
[
'created_by'
]
=
1
;
$user_personals
[
'created'
]
=
$dateNow
;
$user_personals
=
$this
->
UserPersonals
->
patchEntity
(
$user_personals
,
$this
->
request
->
getData
());
$this
->
UserPersonals
->
save
(
$user_personals
);
$this
->
Flash
->
success
(
__
(
'The register success.'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'pinCode/'
.
$users
[
'token'
]]);
return
$this
->
redirect
([
'action'
=>
'signin'
]);
}
$this
->
Flash
->
success
(
__
(
'user or email in program'
));
return
$this
->
redirect
([
'action'
=>
'signup'
]);
}
else
if
(
empty
(
$this
->
request
->
data
[
'accept'
])){
$this
->
Flash
->
success
(
__
(
'please accept'
));
return
$this
->
redirect
([
'action'
=>
'signup'
]);
}
$this
->
Flash
->
error
(
__
(
'The article could not be saved. Please, try again.'
));
}
}
}
else
{
$this
->
Flash
->
error
(
__
(
'Data Empty'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'signin'
]);
public
function
notification
(
$data
=
null
)
{
if
(
!
empty
(
$data
)){
$verify_code
=
$data
[
'pin_code'
];
$from_email
=
[
'support@pakgon.com'
=>
'Support'
];
$to_emails
=
[
$data
[
'email'
]];
$email
=
new
Email
();
$email
->
transport
(
'gmail'
);
try
{
$email
->
template
(
'notification_signup'
,
'connect'
);
$email
->
from
(
$from_email
);
$email
->
to
(
$to_emails
);
$email
->
subject
(
'Signup Connect Verify'
);
$email
->
emailFormat
(
'html'
);
$email
->
viewVars
(
compact
(
'verify_code'
));
#$email->send($message);
$email
->
send
();
}
catch
(
Exception
$e
)
{
echo
'Exception : '
,
$e
->
getMessage
(),
"
\n
"
;
}
#$this->httpStatusCode = 200;
#$this->apiResponse['message'] = 'Signup Connect Completed!!';
}
die
;
}
#---------------------------------------------------------------------------------------------------
...
...
@@ -144,10 +279,10 @@ class UsersController extends AppController
}
public
function
notification
()
{
$this
->
viewBuilder
()
->
layout
(
'blank'
);
}
//
public function notification()
//
{
//
$this->viewBuilder()->layout('blank');
//
}
#Verify Pin Code
public
function
pinCode
(
$token
=
null
)
...
...
@@ -226,19 +361,28 @@ class UsersController extends AppController
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$data
=
$this
->
request
->
data
();
#debug($data);exit();
// pr($data);die;
// pr($this->validateAccount($data));die;
if
(
!
empty
(
$data
)){
// pr($data);die;
if
(
$this
->
validateAccount
(
$data
)){
$data
[
'data'
][
'ip'
]
=
$this
->
request
->
clientIp
();
#debug($data);exit();
// pr($data);die;
$api_core_change_password
=
Configure
::
read
(
'Config.apiCore.changePassword'
);
#debug($api_core_change_password);exit();
$http
=
new
Client
();
// pr($http);die;
#$response = json_decode($http->post($api_core_change_password,$data)->body(),'_full');
$response
=
$http
->
post
(
$api_core_change_password
,
$data
)
->
body
();
// pr($data);die;
#debug($response);exit();
$response
=
json_decode
(
$response
,
'_full'
);
// pr($response);die;
#debug($response);exit();
if
(
!
empty
(
$response
)){
// pr($response);die;
#if(trim($response['status']) == 'Success' && !empty($response['result']['type'])){
if
(
trim
(
$response
[
'status'
])
==
'Success'
){
#$this->response->withHeader('Authorization', 'Bearer '.$response['result']['token']);
...
...
@@ -268,4 +412,5 @@ class UsersController extends AppController
$this
->
checkToken
();
}
}
www/src/Model/Table/UsersTable.php
View file @
5e93d833
...
...
@@ -71,51 +71,51 @@ class UsersTable extends Table {
* @return \Cake\Validation\Validator
*/
public
function
validationDefault
(
Validator
$validator
)
{
$validator
->
allowEmpty
(
'id'
,
'create'
);
//
$validator
//
->allowEmpty('id', 'create');
$validator
->
scalar
(
'username'
)
->
allowEmpty
(
'username'
);
//
$validator
//
->scalar('username')
//
->allowEmpty('username');
$validator
->
scalar
(
'password'
)
->
allowEmpty
(
'password'
);
//
$validator
//
->scalar('password')
//
->allowEmpty('password');
$validator
->
integer
(
'point'
)
->
allowEmpty
(
'point'
);
//
$validator
//
->integer('point')
//
->allowEmpty('point');
$validator
->
boolean
(
'is_used'
)
->
allowEmpty
(
'is_used'
);
//
$validator
//
->boolean('is_used')
//
->allowEmpty('is_used');
$validator
->
scalar
(
'dynamic_key'
)
->
allowEmpty
(
'dynamic_key'
);
//
$validator
//
->scalar('dynamic_key')
//
->allowEmpty('dynamic_key');
$validator
->
date
(
'dynamic_key_expiry'
)
->
allowEmpty
(
'dynamic_key_expiry'
);
//
$validator
//
->date('dynamic_key_expiry')
//
->allowEmpty('dynamic_key_expiry');
$validator
->
scalar
(
'token'
)
->
allowEmpty
(
'token'
);
//
$validator
//
->scalar('token')
//
->allowEmpty('token');
$validator
->
date
(
'token_expiry'
)
->
allowEmpty
(
'token_expiry'
);
//
$validator
//
->date('token_expiry')
//
->allowEmpty('token_expiry');
$validator
->
requirePresence
(
'created_by'
,
'create'
)
->
notEmpty
(
'created_by'
);
//
$validator
//
->requirePresence('created_by', 'create')
//
->notEmpty('created_by');
$validator
->
allowEmpty
(
'modified_by'
);
//
$validator
//
->allowEmpty('modified_by');
$validator
->
scalar
(
'pin_code'
)
->
allowEmpty
(
'pin_code'
);
//
$validator
//
->scalar('pin_code')
//
->allowEmpty('pin_code');
return
$validator
;
}
...
...
www/src/Template/Users/signup.ctp
View file @
5e93d833
...
...
@@ -11,7 +11,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ชื่อ');?><em>* </em></label>
<input type="text" name="
data[firstname]" value=""
placeholder="FIRSTNAME" class="form-control-reg border-bottom-from" id="inputSuccess">
<input type="text" name="
firstname" value=""
placeholder="FIRSTNAME" class="form-control-reg border-bottom-from" id="inputSuccess">
</div>
</div>
...
...
@@ -20,7 +20,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('นามสกุล');?><em>* </em></label>
<input type="text" name="
data[lastname]" value=""
placeholder="LASTNAME" class="form-control-reg border-bottom-from" id="inputSuccess">
<input type="text" name="
lastname" value=""
placeholder="LASTNAME" class="form-control-reg border-bottom-from" id="inputSuccess">
</div>
</div>
...
...
@@ -29,16 +29,61 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ชื่อผู้ใช้งาน');?><em>* </em></label>
<input type="text" name="
data[username]" value=""
placeholder="USERNAME" class="form-control-reg border-bottom-from" id="inputSuccess">
<input type="text" name="
username" value=""
placeholder="USERNAME" class="form-control-reg border-bottom-from" id="inputSuccess">
</div>
</div>
</div>
<div>
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ประเทศ');?><em>* </em></label>
<?php
echo $this->Form->input( 'master_country_id', array(
'name'=>'master_country_id',
'id'=>'master_country_id',
'label' => false,
'type' => 'select',
'options' => $countries,
'empty' => '---Select---',
'default' => '',
'class' => 'form-control border-bottom-from label-text-sub required',
'style' => 'width:100%'
));
?>
</div>
</div>
</div>
<div>
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('จังหวัด');?><em>* </em></label>
<?php
echo $this->Form->input( 'master_province_id', [
'name'=>'master_province_id',
// 'id'=>'master_province_id',
'label' => false,
'type' => 'select',
'options' => $provinces,
'empty' => '---Select---',
'default' => '',
'class' => 'form-control border-bottom-from label-text-sub required',
'style' => 'width:100%'
]);
?>
</div>
</div>
</div>
<div>
<div class="form-group has-feedback bootstrap-iso">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('วันเกิด');?></label>
<input type="text" name="
data[birthdate]" id="date"
placeholder="กรุณาระบุวันเดือนปีเกิด" value="" placeholder="DD-MM-YYYY" data-date-format="mm/dd/yyyy" class="form-control-reg border-bottom-from">
<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">
<span class="glyphicon glyphicon-calendar form-control-feedback"></span>
</div>
</div>
...
...
@@ -48,7 +93,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('เบอร์โทรศัพท์');?></label>
<input type="text" name="
data[phone_no]" onkeypress="check_phone();" value="" maxlength="10"
placeholder="0000000000" class="mask form-control-reg border-bottom-from" id="inputSuccess">
<input type="text" name="
phone_no" onkeypress="check_phone();" value="" maxlength="10"
placeholder="0000000000" class="mask form-control-reg border-bottom-from" id="inputSuccess">
</div>
</div>
...
...
@@ -57,7 +102,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('อีเมลล์');?><em>* </em></label>
<input type="text" name="
data[email]
" id="fremail" value="" placeholder="mail@xxx.com" class="form-control-reg border-bottom-from" id="inputSuccess">
<input type="text" name="
email
" id="fremail" value="" placeholder="mail@xxx.com" class="form-control-reg border-bottom-from" id="inputSuccess">
</div>
</div>
...
...
@@ -66,7 +111,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('รหัสผ่าน');?></label>
<input data-toggle="password" data-placement="before" type="password" name="
data[password]" value=""
placeholder="********" class="form-control input-lg color-button-border border-bottom-from" id="FALSE" style="padding:0px 0px !important;">
<input data-toggle="password" data-placement="before" type="password" name="
password" value=""
placeholder="********" class="form-control input-lg color-button-border border-bottom-from" id="FALSE" style="padding:0px 0px !important;">
<!--<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>
...
...
@@ -76,7 +121,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ยืนยันรหัสผ่าน');?><em>* </em></label>
<input data-toggle="password" data-placement="before" type="password" name="
data[confirm_password]" value=""
placeholder="********" class="form-control input-lg color-button-border border-bottom-from" id="FALSE" style="padding:0px 0px !important;">
<input data-toggle="password" data-placement="before" type="password" name="
confirm_password" value=""
placeholder="********" class="form-control input-lg color-button-border border-bottom-from" id="FALSE" style="padding:0px 0px !important;">
<!--<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>
...
...
@@ -106,7 +151,7 @@
</div>
<!------------------Exit Model---------------------->
<div class="switch switch-lg switch-warning" style="padding: 10px 0px 30px 0px;">
<input type="checkbox"
name="data[accept]
" data-plugin-ios-switch data-toggle="modal" data-target="#largeModal"/>
<input type="checkbox"
id="accept" name="accept
" data-plugin-ios-switch data-toggle="modal" data-target="#largeModal"/>
<span style="font-size: 17px;"><?php echo __('กรุณายอมรับ <b>เงื่อนไขการใช้งาน</b>');?></span>
</div>
...
...
@@ -120,63 +165,65 @@
<?php echo $this->Form->end(); ?>
</div>
</div>
<!--
------------------------------- popup -----------------------------------
-->
<!--
------------------------------- popup -----------------------------------
-->
<script>
function validateForm() {
var firstname = document.forms["createAccount"]["
data[firstname]
"].value;
var firstname = document.forms["createAccount"]["
firstname
"].value;
if (firstname == null || firstname == "") {
alert("กรุณากรอกชื่อ");
return false;
}
var lastname = document.forms["createAccount"]["
data[lastname]
"].value;
var lastname = document.forms["createAccount"]["
lastname
"].value;
if (lastname == null || lastname == "") {
alert("กรุณากรอกนามสกุล");
return false;
}
var username = document.forms["createAccount"]["
data[username]
"].value;
var username = document.forms["createAccount"]["
username
"].value;
if (username == null || username == "") {
alert("กรุณากรอกชื่อผู้ใช้งานของท่าน");
return false;
}
if(document.forms["createAccount"]["
data[username]
"].value.length < 5)
if(document.forms["createAccount"]["
username
"].value.length < 5)
{
alert('กรุณาระบุชื่อผู้ใช้งานอย่างน้อย 5 ตัวอักษร');
return false;
}
/*
var birthdate = document.forms["createAccount"]["data[birthdate]"].value;
var birthdate = document.forms["createAccount"]["birthdate"].value;
if (birthdate == null || birthdate == "") {
alert("กรุณากรอก วันเดือนปีเกิดของท่าน");
return false;
}
var person_card_no = document.forms["createAccount"]["data[person_card_no]
"].value;
if (person_card_no == null || person_card_no == "") {
alert("กรุณากรอกเลขบัตรประชาชน");
return false;
}
if(document.forms["createAccount"]["data[person_card_no]"].value.length < 13 || document.forms["createAccount"]["data[person_card_no]"].value.length > 13)
{
alert('กรุณากรอกเลขบัตรประชาชนให้ครบ 13 หลัก');
return false;
}
var phone_no = document.forms["createAccount"]["
data[phone_no]
"].value;
// var person_card_no = document.forms["createAccount"]["person_card_no
"].value;
//
if (person_card_no == null || person_card_no == "") {
//
alert("กรุณากรอกเลขบัตรประชาชน");
//
return false;
//
}
//
if(document.forms["createAccount"]["data[person_card_no]"].value.length < 13 || document.forms["createAccount"]["data[person_card_no]"].value.length > 13)
//
{
//
alert('กรุณากรอกเลขบัตรประชาชนให้ครบ 13 หลัก');
//
return false;
//
}
var phone_no = document.forms["createAccount"]["
phone_no
"].value;
if (phone_no == null || phone_no == "") {
alert("กรุณากรอกเบอร์โทรศัพท์ของท่าน");
alert("กรุณากรอก
เบอร์โทรศัพท์ของท่าน");
return false;
}
if(document.forms["createAccount"]["data[phone_no]"].value.length < 10 || document.forms["createAccount"]["data[phone_no]
"].value.length > 10)
if(document.forms["createAccount"]["phone_no"].value.length < 10 || document.forms["createAccount"]["phone_no
"].value.length > 10)
{
alert('กรุณากรอกเบอร์โทรศัพท์ ให้ครบ 10 หลัก');
return false;
}
*/
/*var lastname = document.forms["createAccount"]["data[lastname]"].value;
if (lastname == null || lastname == "") {
alert("กรุณากรอกรหัสผ่าน");
return false;
}*/
var email = document.forms["createAccount"]["data[email]"].value;
// var lastname = document.forms["createAccount"]["data[lastname]"].value;
// if (lastname == null || lastname == "") {
// alert("กรุณากรอกรหัสผ่าน");
// return false;
// }
var email = document.forms["createAccount"]["email"].value;
if (email == null || email == "") {
alert("กรุณากรอกอีเมลล์");
return false;
...
...
@@ -187,28 +234,40 @@
alert("รูปแบบที่อยู่อีเมลล์ผิด กรุณากรอกให้ถูกต้อง");
return false;
}
var password = document.forms["createAccount"]["
data[password]
"].value;
var password = document.forms["createAccount"]["
password
"].value;
if (password == null || password == "") {
alert("กรุณากรอกรหัสผ่าน");
return false;
}
if(document.forms["createAccount"]["
data[password]
"].value.length < 8)
if(document.forms["createAccount"]["
password
"].value.length < 8)
{
alert('กรุณาระบุรหัสผ่านอย่างน้อย 8 ตัวอักษร');
return false;
}
var confirm_password = document.forms["createAccount"]["
data[confirm_password]
"].value;
var confirm_password = document.forms["createAccount"]["
confirm_password
"].value;
if (confirm_password == null || confirm_password == "") {
alert("กรุณายืนยันรหัสผ่าน");
return false;
}
if(document.forms["createAccount"]["
data[password]"].value != document.forms["createAccount"]["data[confirm_password]
"].value){
if(document.forms["createAccount"]["
password"].value != document.forms["createAccount"]["confirm_password
"].value){
alert('กรุณาระบุรหัสผ่านให้ตรงกัน');
//document.createAccount.confirm_password.focus();
return false;
}
$("body").delegate(".is_active", "click", function () {
$('.is_active').not(this).prop('checked', false);
return true;
// var id = $(this).closest('td').find('#idAddresses').val();
// var id_card13 = $(this).closest('td').find('#idCard13Addresses').val();
// console.log(id);
// $.post("/Addresses/currentAddress", {id: id, id_card13 : id_card13}, function(data) {
// location.reload();
// });
});
}
</script>
<style>
#alertBox {
...
...
@@ -371,17 +430,47 @@
alert('Alert this pages');
}
</script>
<!--------------------------------- confirm password -------------------------------->
<script>
function check_number() {
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k = 13 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false;
alert("ขออภัยหมายเลขบัตรประจำตัวประชาชน ต้องเป็นตัวเลขเท่านั้น");
<script type="text/javascript">
$(document).ready(function() {
$(document).ready(function() {
$("#loding1").hide();
$("#loding2").hide();
$("#master_country_id").on('change',function() {
var id = $(this).val();
$("#loding1").show();
$("#master_province_id").find('option').remove();
// alert('dddd');
if (id) {
var dataString = 'id='+ id;
$.ajax({
type: "POST",
url: 'users/getStates' ,
data: dataString,
cache: false,
success: function(html) {
$("#loding1").hide();
$.each(html, function(key, value) {
$('<option>').val('').text('---Select---');
$('<option>').val(key).text(value).appendTo($("#master_province_id"));
});
}
});
}
});
});
});
</script>
<!--------------------------------- confirm password ------------------------------ -->
<script>
function check_phone() {
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment