/home/mip/mip/app/Modules/Client/Views/principals/contact-persons/includes/js.blade.php
<script type="text/javascript" src="{{ asset('vendor/jsvalidation/js/jsvalidation.js')}}"></script>
{!! JsValidator::formRequest('QxCMS\Modules\Client\Requests\Principals\ContactPersonRequest', '#contact-person-form'); !!}
<script type="text/javascript">
$(function(){
var body = $('body');
var form = $('form#contact-person-form');
$('button.save-btn').on('click', function() {
var btn = $(this);
btn.button('loading');
if(btn.hasClass('btn-warning')) $('a.btn-cancel').hide();
if(form.valid()) return true;
setTimeout(function(){
btn.button('reset');
if(btn.hasClass('btn-warning')) $('a.btn-cancel').show();
}, 200);
return false;
});
$(".intlphone").intlTelInput({
//allowExtensions:true,
autoFormat:true,
numberType:"MOBILE",
//autoPlaceholder:false,
defaultCountry: "ph",
//autoHideDialCode: false,
// nationalMode:true,
utilsScript: body.data('url')+'/template/AdminLTE/plugins/intlnum/lib/libphonenumber/build/utils.js'
});
$('body').on('click', 'button.add-contact-btn', function(e){
var counter = form.find('input[name^="contact"]').length + 1;
var limit = 5;
if (counter > limit) {
swal('',"You have reached the maximum limit of contact.", 'error');
return false
}
var new_input = "<div class=\"form-group\">";
new_input += "<label class=\"control-label col-md-2\"></label>";
new_input += "<div class=\"col-md-6\">";
new_input += "<div class=\"input-group\">"
new_input += "<input type=\"text\" name=\"contact[new_"+counter+"]\" class=\"form-control intlphone\" style=\"width:100%\">";
new_input += "<div class=\"input-group-btn\">";
new_input += "<button class=\"btn btn-flat btn-danger remove-contact-btn\" type=\"button\"><i class=\"fa fa-times\"></i></button>";
new_input += "</div>";
new_input += "</div>";
new_input += "</div>";
new_input += "</div>";
$(this).closest('.form-group').parent().append(new_input);
$(".intlphone").intlTelInput({
//allowExtensions:true,
autoFormat:true,
numberType:"MOBILE",
//autoPlaceholder:false,
defaultCountry: "ph",
//autoHideDialCode: false,
// nationalMode:true,
utilsScript: body.data('url')+'/template/AdminLTE/plugins/intlnum/lib/libphonenumber/build/utils.js'
});
return false;
});
$('body').on('click', 'button.remove-contact-btn', function(e){
$(this).closest('.form-group').remove();
});
});
</script>