igorescobar / jQuery-Mask-Plugin

A jQuery Plugin to make masks on form fields and HTML elements.
http://igorescobar.github.io/jQuery-Mask-Plugin/
Other
4.77k stars 1.42k forks source link

Uso da biblioteca no LARAVEL #702

Closed mfrancaleal closed 5 years ago

mfrancaleal commented 5 years ago

Estou com dificuldades de integrar a biblioteca com o Laravel, precisamente na utilização no FORM.

Grato.

Have you take a look into our docs?

https://igorescobar.github.io/jQuery-Mask-Plugin/

Make sure your read this before opening a new issue:

https://github.com/igorescobar/jQuery-Mask-Plugin#problems-or-questions

Device

[...]

Browser (and version)?

[...]

Functional jsfiddle exemplifying your problem:

You can use this one as exemple: http://jsfiddle.net/igorescobar/6pco4om7/

Describe de problem depth:

[...]

Is this plugin helping you out? Buy me a beer and cheers! :beer:

:bowtie: https://www.paypal.me/igorcescobar

mfrancaleal commented 5 years ago

Consegui.

lordjack commented 3 years ago

Consegui.

Consegui também usar a biblioteca jQuery-Mask-Plugin no Laravel, compartilho a minha solução.

<!doctype html>
<head>
</head>
 <!-- resources/views/layouts/app.blade.php -->
<body>
    <div id="app">
        @yield('content')
    </div>

    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.16/jquery.mask.js"
        integrity="sha256-yE5LLp5HSQ/z+hJeCqkz9hdjNkk1jaiGG0tDCraumnA=" crossorigin="anonymous"></script>

<!-- Carrega o Script Personalizado na Página aqui -->
    @yield("script")

</body>
</html>

Formulário Cadastrar

 <!-- resources/views/user/create.blade.php -->
@extends('layouts.app')

@section('script')
<script>
    $(document).ready(function($){
        $('#cpf').mask('999.999.999-99');
   });
</script>
@endsection

@section('content')
<form class="form-group" action="{{ action('UserController@store', 0) }}" method="post">
    @csrf
    <div class="col-md-2">
        <label>CPF</label><br>
        <input class="form-control" id="cpf" type="text" name="cpf" required><br>
    </div>
</form>

@stop