gpt4 book ai didi

javascript - 模态 Laravel 5.1

转载 作者:行者123 更新时间:2023-11-28 07:02:27 25 4
gpt4 key购买 nike

我有这个代码:

<!-- line modal -->
<div class="modal fade" id="squarespaceModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="lineModalLabel">Prašymas Dėl Pakvietimo</h3>
</div>
<div class="modal-body">

<!-- content goes here -->

@if($errors->any())
@foreach($errors->all() as $error)
<ul class="list-unstyled">
<li class="alert alert-danger">{{$error}}</li>
</ul>
@endforeach
@endif


{!! Form::open(['url' => 'sukurti', 'id' => 'frm']) !!}

@include('components.forma')

{!! Form::close() !!}


</div>
</div>
</div>
</div>

我想要做的是在不关闭模式的情况下显示错误。因为如果现在我留下空白并按提交,模式将关闭,如果我再按一次按钮以显示模式,我就看不到错误。如何使当空格为空白时我按输入模式不会关闭并只是停留但有错误?

最佳答案

要像这样工作,您必须在代码中进行一些调整。

Jquery 将处理您的提交操作。创建一个提交事件,例如;

$('#frm').submit(function(e){
//stop default submit
e.preventDefault();
//make checks here now check for space .
var field = trim($('fieldname').val());
//of course you can apply some jquery validation library here too .
if(field.length > 0){
//submit form but you need to perform ajax for saving data here
//on ajax success close you modal
//here if you have some server side validation error then show them here without closing modal
//laravel give you error in json array form . foreach and append them on ul tag .
//$error = []; $.each(errors , function(val){$error[] = "<li>"+val+"</li>";}); $('ulid or class').html(error);
//empty html of this ulid or class if there is no error
// $('#squarespaceModal').modal('hide');

}else{
//show error
$('ulid or class').html('<li>This is error</li>');
}

})

这是基本思想,即如何实现目标。

关于javascript - 模态 Laravel 5.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32005287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com