Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready( function () {
- $('#areaDT').DataTable();
- });
- function save() {
- var name = $("#name").val().toUpperCase();
- var description = $("#description").val().toUpperCase();
- var regexSpesialChar = /^[a-zA-Z0-9 ]+$/;
- var regexNumeric = /^[0-9]+$/;
- if(name == "" || description == ""){
- swal('Peringatan', 'Tolong lengkapi data dengan benar!', 'warning');
- } else {
- if(name.match(regexSpesialChar) && description.match(regexSpesialChar)){
- $.ajax({
- cache: false,
- dataType: "json",
- type: "post",
- url: "http://localhost/saber-cia/area/save",
- data: {name : name,
- description : description},
- success: function(res){
- if(res.code == 200){
- swal('Berhasil', 'Kamu berhasil menambahkan data baru!', 'success');
- } else {
- swal('Gagal', 'Kamu gagal menambahkan data baru!', 'error');
- }
- }
- });
- } else {
- swal('Peringatan', 'Format data tidak valid!', 'warning');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement