Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在jquery中输入最小长度?_Javascript_Jquery_Laravel - Fatal编程技术网

Javascript 在jquery中输入最小长度?

Javascript 在jquery中输入最小长度?,javascript,jquery,laravel,Javascript,Jquery,Laravel,我试图在jquery中的插件live搜索中设置最小长度。我完成了搜索时连接到我的表的实时搜索。但是我想通过我的实时搜索进行一些验证,比如用户必须在搜索开始之前输入至少3个字符。。我试图通过我的js输入minlength,但它不起作用。。有什么建议吗 查看 @extends('layout.default') @section('content') <br><br> <br><br> <div class="container">

我试图在jquery中的插件live搜索中设置最小长度。我完成了搜索时连接到我的表的实时搜索。但是我想通过我的实时搜索进行一些验证,比如用户必须在搜索开始之前输入至少3个字符。。我试图通过我的js输入minlength,但它不起作用。。有什么建议吗

查看

@extends('layout.default')
@section('content')
<br><br>
<br><br>
<div class="container">
    <h4>Live Search using Laravel</h4>
    <div class="col-md-6 col-lg-6 pull-right" >
        <p class="pull-right">Click on the zip logo to download the file:<p>
            <a href="/live_search_laravel.zip" download="live-search(laravel).zip">
                <br><br>
                <img border="0" src="/images/ziplogo.png" class="pull-right" alt="AngularJS" width="50" height="42">
            </a>
        </div>
    </div>
    <br>
    <div class="col-md-12 col-sm-6 col-xs-12">
        <div class="x_panel">

            <div class="x_content">
                <table class="search-table table table-hover">
                    <thead>
                    <tr>

                        <th>
                            Original File Name
                        </th>
                        <th>
                            Change File Name
                        </th>
                        <th>
                            File Extension
                        </th>
                        <th>
                            Image
                        </th>
                        <th>
                            Category
                        </th>
                        <th>
                            Status
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($data as $file)
                    <tr>

                        <td>{{ $file->original_filename}}</td> 
                        <tD>{{ $file->rs_filename}}</td>
                        <td>{{ $file->file_extension}}</td>
                        <td><img src = "files/images/{{ $file->rs_filename}}"></td>
                        <td>@if($file->category=="1"){{ "Laravel" }}@endif</td>
                        <td>
                            @if($file->status=="0")
                            <form action="/activateImage/{{  $file->id}}" method="post">
                                <input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
                                <button type="submit" class="btn btn-primary">Activate</button>
                            </form>
                            @else
                            <form action="{{ url('deactivateImage', ['id' => $file->id]) }}" method="post">
                                <input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
                                <button type="submit" class="btn btn-primary">Deactivate</button>
                            </form>
                            @endif
                        </td>

                    </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <h4>All Activated Images using Foreach</h4>
    @foreach($data as $file)


    @if($file->status=="1")
    <div class ="row">
        <div class ="form-group">
            <img src="/files/images/{{ $file->rs_filename }} "  width ="50px" height ="50px">
        </div>
    </div>
    @endif
    @endforeach
    <h4>All Images using the index</h4>
    <div class ="row">
        <div class ="form-group">
            <img src="/files/images/{{ $data[0]['rs_filename']}} "  width ="50px" height ="50px">
        </div>
    </div>
    <div class="col-md-6 col-lg-4 pull-right">
        <img src="/files/images/{{ $data[1]['rs_filename']}} "  width ="50px" height ="50px">

    </div>
    @stop
    @section('select2_js')
    <script type="text/javascript" src="/js/live_search_laravel/select2.js"></script>

    @stop

是的,先生,我进口了所有需要进口的东西。。就像他的链接一样,html表格搜索代码的文件实际上需要一些严重的重构。哈哈,我明白了。。我现在明白了..
我试图通过我的js输入minlength,但它不起作用。。有什么建议吗?
因为插件不接受
minlength
选项
    /**
    **options to have following keys:
        **searchText: this should hold the value of search text
        **searchPlaceHolder: this should hold the value of search input box placeholder
**/
(function($){
    $.fn.tableSearch = function(options){
        if(!$(this).is('table')){

            return;
        }
        var tableObj = $(this),

            searchText = (options.searchText)?options.searchText:'Search: ',
            searchPlaceHolder = (options.searchPlaceHolder)?options.searchPlaceHolder:'',
            divObj = $('<div style="font-size:20px;">'+searchText+'</div><br /><br />'),
            inputObj = $('<input style="min-width:25%;max-width:50%;margin-left:1%" type="text" placeholder="'+searchPlaceHolder+'" />'),
            caseSensitive = (options.caseSensitive===true)?true:false,
            searchFieldVal = '',
            pattern = '';
        inputObj.off('keyup').on('keyup', function(){
            searchFieldVal = $(this).val();

            if(searchFieldVal.length >= 3)
            {
                pattern = (caseSensitive)?RegExp(searchFieldVal):RegExp(searchFieldVal, 'i');
                tableObj.find('tbody tr').hide().each(function(){
                    var currentRow = $(this);
                    currentRow.find('td').each(function(){
                        if(pattern.test($(this).html())){
                            currentRow.show();
                            return false;
                        }
                    });
                });
            }


        });
        tableObj.before(divObj.append(inputObj));
        return tableObj;
    }
}(jQuery));
$(document).ready(function(){
                $('table.search-table').tableSearch({
                    searchText:'Search:'
                });
            });