eyoku_

Untitled

Jun 16th, 2020
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. <div class="card">
  2. <div class="card-header">
  3. <h4>User's Update</h4>
  4. </div>
  5. <div class="card-body">
  6. <form id="form-update-barang" enctype="multipart/form-data" method="post"
  7. action="<?= site_url("user/proses_update") ?>">
  8. <div class="form-group">
  9. <label for="nama-user">User's Name</label>
  10. <input value="<?= $user->nama_user ?>" required type="text" maxlength="20" name="nama" id="nama_user" class="form-control"/>
  11. </div>
  12. <div class="form-group">
  13. <label for="email-user">User's Email</label>
  14. <input value="<?= $user->email_user ?>" required type="text" name="email" id="email_user" class="form-control"/>
  15. </div>
  16. <div class="form-group">
  17. <label for="">User's Role</label>
  18. <select name="role" id="" required class="form-control">
  19. <option value="<?=$user->role_user?>" disabled selected><?=$user->role_user?></option>
  20. <option value="Admin" value="<?= $user->role_user ?>">Admin</option>
  21. <option value="Kasir" value="<?= $user->role_user ?>">Cashier</option>
  22. </select>
  23. </div>
  24. <input type="hidden" name="id" value="<?= $user->id_user ?>" />
  25. </form>
  26. </div>
  27. <div class="card-footer">
  28. <button id="btn-save-barang" type="button" class="btn btn-success">
  29. <i class="fas fa-save"></i> Save
  30. </button>
  31. </div>
  32. </div>
  33. <script>
  34. $(function () {
  35. $("#btn-save-barang").on("click", function () {
  36. let validate = $("#form-update-barang").valid();
  37. if(validate){
  38. $("#form-update-barang").submit();
  39. }
  40. });
  41. $("#form-update-barang").validate({
  42. rules: {
  43. kode: {
  44. alphanumeric: true
  45. },
  46. harga: {
  47. digits: true
  48. },
  49. stock: {
  50. digits: true
  51. }
  52. },
  53. messages: {
  54. kode: {
  55. alphanumeric: "Hanya Boleh Angka, Huruf dan Undescore"
  56. }
  57. },
  58. errorElement: 'span',
  59. errorPlacement: function (error, element) {
  60. error.addClass('invalid-feedback');
  61. element.closest('.form-group').append(error);
  62. },
  63. highlight: function (element, errorClass, validClass) {
  64. $(element).addClass('is-invalid');
  65. },
  66. unhighlight: function (element, errorClass, validClass) {
  67. $(element).removeClass('is-invalid');
  68. }
  69. });
  70. });
  71. </script>
Add Comment
Please, Sign In to add comment