Advertisement
jamboljack

Register Pasar

Dec 6th, 2017
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.81 KB | None | 0 0
  1. <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>backend/js/sweetalert2.css">
  2. <script src="<?php echo base_url(); ?>backend/js/sweetalert2.min.js"></script>
  3.  
  4. <div class="main-section">
  5.     <br /><br /><br />
  6.     <div class="container" style="background-color: #fff; padding:  20px;margin-bottom: 100px;">
  7.         <div class="col-md-6 no-padding">
  8.             <h3 style="margin-left: 15px;">Daftar</h3>
  9.             <form method="post" id="formInput" role="form">
  10.                 <div class="form-body">
  11.                     <div class="form-group col-md-12">
  12.                         <label class="control-label">Username</label>
  13.                         <input type="text" name="username" class="form-control" id="username" autocomplete="off" autofocus required>
  14.                     </div>
  15.                     <div class="form-group col-md-12">
  16.                         <label class="control-label">Nama Lengkap</label>
  17.                         <input type="text" name="name" class="form-control" autocomplete="off" required>
  18.                     </div>
  19.                     <div class="form-group col-md-6">
  20.                         <label class="control-label">Password</label>
  21.                         <input type="password" name="password" class="form-control" id="password" autocomplete="off" required>
  22.                     </div>
  23.                     <div class="form-group col-md-6">
  24.                         <label class="control-label">Konfirmasi Password</label>
  25.                         <input type="password" name="passwordconfirm" class="form-control" id="passwordconfirm" autocomplete="off" required>
  26.                     </div>
  27.                     <div class="form-group col-md-6">
  28.                         <label class="control-label">Email</label>
  29.                         <input type="text" name="email" class="form-control" id="email" autocomplete="off" required>
  30.                     </div>
  31.                     <div class="form-group col-md-6">
  32.                         <label class="control-label">Konfirmasi Email</label>
  33.                         <input type="text" name="emailconfirm" class="form-control" id="emailconfirm" autocomplete="off" required>
  34.                     </div>         
  35.                         <!-- <div class="col-sm-6">
  36.                             <label><input type="checkbox" name="remember" id="remember"> Sigh up for our newsletter</label>
  37.                         </div>
  38.                         <div class="col-sm-6">
  39.                             <label><input type="checkbox" name="notifications" id="remember"> Send notifications to this email</label>
  40.                         </div> -->
  41.                     <div class="col-sm-12">
  42.                         <button type="submit" class="btn btn-primary">Daftar</button>
  43.                         <label>Punya Akun ? <a href="<?php echo site_url('login'); ?>">Login</a></label>
  44.                     </div>
  45.                 </div>
  46.             </form>
  47.         </div>
  48.         <div class="col-md-6">
  49.             <h3 class="">Terms and Conditions</h3>
  50.             <p>By clicking on "Register" you agree to The Company's' Terms and Conditions</p>
  51.             <p>While rare, prices are subject to change based on exchange rate fluctuations - should such a fluctuation happen, we may request an additional payment. You have the option to request a full refund or to pay the new price. (Paragraph 13.5.8)</p>
  52.             <p>Should there be an error in the description or pricing of a product, we will provide you with a full refund (Paragraph 13.5.6)</p>
  53.             <p>Acceptance of an order by us is dependent on our suppliers ability to provide the product. (Paragraph 13.5.6)</p>
  54.         </div>
  55.     </div>
  56. </div>
  57.  
  58. <script type="text/javascript" src="<?php echo base_url(); ?>backend/assets/global/plugins/jquery-validation/js/jquery.validate.min.js"></script>
  59. <script type="text/javascript">
  60. $.validator.addMethod("alphanumeric", function(value, element) {
  61.     return this.optional(element) || /^\w+$/i.test(value);
  62. }, "Hanya Huruf, Angka dan Garis Bawah");
  63.  
  64. $(document).ready(function() {
  65.     var form        = $('#formInput');
  66.     var error       = $('.alert-danger', form);
  67.     var success     = $('.alert-success', form);
  68.    
  69.     $("#formInput").validate({
  70.         errorElement: 'span',
  71.         errorClass: 'help-block help-block-error',
  72.         focusInvalid: false,
  73.         ignore: "",
  74.         rules: {
  75.             username: {
  76.                 required: true, minlength: 5, alphanumeric: true,
  77.                 remote: {
  78.                     url: "<?php echo site_url('register/register_user_exists'); ?>",
  79.                     type: "post",
  80.                     data: {
  81.                         username: function() {
  82.                             return $("#username").val();
  83.                         }
  84.                     }
  85.                 }
  86.             },
  87.             name: {
  88.                 required: true,
  89.                 minlength: 5
  90.             },
  91.             password: {
  92.                 required: true,
  93.                 minlength: 5
  94.             },
  95.             passwordconfirm: {
  96.                 required: true,
  97.                 minlength: 5,
  98.                 equalTo: "#password"
  99.             },
  100.             email: {
  101.                 required: true,
  102.                 email: true,
  103.                 remote: {
  104.                     url: "<?php echo site_url('register/register_email_exists'); ?>",
  105.                     type: "post",
  106.                     data: {
  107.                         email: function() {
  108.                             return $("#email").val();
  109.                         }
  110.                     }
  111.                 }
  112.             },
  113.             emailconfirm: {
  114.                 required: true,
  115.                 email: true,
  116.                 equalTo: "#email"
  117.             }
  118.         },
  119.         messages: {
  120.             username: {
  121.                 required:'Username harus diisi',
  122.                 minlength:'Minimal 5 Karakter',
  123.                 remote: 'Username ini sudah Ada'
  124.             },
  125.             name: {
  126.                 required:'Nama Lengkap harus diisi',
  127.                 minlength:'Minimal 5 Karakter'
  128.             },
  129.             password: {
  130.                 required:'Password harus diisi',
  131.                 minlength:'Minimal 5 Karakter'
  132.             },
  133.             passwordconfirm: {
  134.                 required:'Konfirmasi Password harus diisi',
  135.                 minlength:'Minimal 5 Karakter',
  136.                 equalTo:'Konfirmasi Password tidak sama.'
  137.             },
  138.             email: {
  139.                 required:'Email harus diisi',
  140.                 email:'Email tidak Valid',
  141.                 remote: 'Email ini sudah Terdaftar'
  142.             },
  143.             emailconfirm: {
  144.                 required:'Konfirmasi Email harus diisi',
  145.                 email:'Email tidak Valid',
  146.                 equalTo:'Konfirmasi Email tidak sama.'
  147.             }
  148.         },
  149.         invalidHandler: function (event, validator) {
  150.             success.hide();
  151.             error.show();
  152.             // Metronic.scrollTo(error1, -200);
  153.         },
  154.         highlight: function (element) {
  155.             $(element)
  156.             .closest('.form-group').addClass('has-error');
  157.         },
  158.         unhighlight: function (element) {
  159.             $(element)
  160.             .closest('.form-group').removeClass('has-error');
  161.         },
  162.         success: function (label) {
  163.             label
  164.             .closest('.form-group').removeClass('has-error');
  165.         },
  166.         submitHandler: function(form) {
  167.             dataString = $("#formInput").serialize();
  168.  
  169.             $.ajax({
  170.                 url: "<?php echo site_url('register/savedata'); ?>",
  171.                 type: "POST",
  172.                 data: dataString,
  173.                 success: function(data) {
  174.                     setTimeout(function() {
  175.                         swal({
  176.                             title:"Sukses",
  177.                             text: "Pendaftaran Anda Berhasil",
  178.                             timer: 2000,
  179.                             showConfirmButton: false,
  180.                             type: "success"
  181.                         })
  182.                     });
  183.                 },
  184.                 error: function() {
  185.                     setTimeout(function() {
  186.                         swal({
  187.                             title:"Error",
  188.                             text: "Pendaftaran Anda Gagal",
  189.                             timer: 2000,
  190.                             showConfirmButton: false,
  191.                             type: "error"
  192.                         })
  193.                     });
  194.                 }
  195.             });
  196.         }
  197.     });
  198. });
  199. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement