Advertisement
eyoku_

Untitled

Jun 16th, 2020
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <div class="card">
  2. <div class="card-header">
  3. <h4>Add User</h4>
  4. </div>
  5. <div class="card-body">
  6. <form id="form-tambah" method="post" action="<?= site_url("user/proses_simpan") ?>">
  7. <div class="form-group">
  8. <label for="">User's Name</label>
  9. <input required type="text" maxlength="20" name="nama_user" class="form-control"/>
  10. </div>
  11. <div class="form-group">
  12. <label for="">User's Email</label>
  13. <input required type="email" name="email_user" class="form-control"/>
  14. </div>
  15. <div class="form-group">
  16. <label for="">User's Role</label>
  17. <select name="role_user" id="" required class="form-control">
  18. <option value="" disabled selected>Select the role</option>
  19. <option value="admin">Admin</option>
  20. <option value="kasir">Cashier</option>
  21. </select>
  22. </div>
  23. </form>
  24. </div>
  25. <div class="card-footer">
  26. <button id="btn-save-barang" type="button" class="btn btn-success">
  27. <i class="fas fa-save"></i> Save
  28. </button>
  29. </div>
  30. </div>
  31. <script>
  32. $(function () {
  33. $("#btn-save-barang").on("click", function () {
  34. let validate = $("#form-tambah").valid();
  35. if(validate){
  36. $("#form-tambah").submit();
  37. }
  38. });
  39. $("#form-tambah-barang").validate({
  40. errorElement: 'span',
  41. errorPlacement: function (error, element) {
  42. error.addClass('invalid-feedback');
  43. element.closest('.form-group').append(error);
  44. },
  45. highlight: function (element, errorClass, validClass) {
  46. $(element).addClass('is-invalid');
  47. },
  48. unhighlight: function (element, errorClass, validClass) {
  49. $(element).removeClass('is-invalid');
  50. }
  51. });
  52. });
  53. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement