how to use Ajax with laravel

Autocomplete search with ajax in laravel ……….

1. View page code …..

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js”></script&gt;
<script>
$(document).ready(function(){
$(“#add_b”).click(function(){
$(“#add_board”).slideToggle(“slow”);
});
$(‘form#sv’).submit(function() {
var nam = $(‘input[name=name]’).val();

if(nam!=””)
{

$.ajax({
type: “POST”,
data: { name: nam}
}).done(function( msg ) {

$(“#mks”).html(msg);
//$(“.team_sec”).html(msg[‘results’]);
});
}
else
{
$(“#mess”).html(“<span class=’rd’>Please fill name!</span>”);
}
return false;
});
});
</script>

<div class=”ad_board” id=”add_board”>

{{ Form::open([‘url’ => ‘admin/settings’, ‘method’ => ‘post’,’name’ => ‘form’, ‘id’ => ‘sv’ ]) }}

<div class=”input_b”>
{{Form::text(‘name’, null,array(‘placeholder’ => ‘Add Board name’,’class’ => ‘form-control’,’id’ => ‘input-name’))}}
<div id=”mks”>

ajax code display ….

</div>
</div>

<div class=”input_b”>
{{Form::submit(‘Save’, array(‘name’ => ‘save’,’class’ => ‘btn btn-primary save-board’))}}
</div>

{{ Form::close() }}

</div>

2. Controller function code …..

public function boardadd()
{
$my_data = Input::get(‘name’);
$results = DB::select(“SELECT * FROM users WHERE username LIKE ‘%$my_data%'”);
$html=”<table>”;
foreach($results as $result)
{
$html.=”<tr><td>$result->username”;
$html.=”</td></tr>”;
}
$html.=”</table>”;

return $html;
}

Note:- Please replace ` `  to ‘ ‘ before use

Comman validation in laravel

$rules = array(
‘categoryname’                => ‘required|alpha’,
‘childrenacceptjesus’         => ‘required|numeric’,
‘file’                        => ‘required|max:10000’,
‘childrengraduated’           => ‘required|numeric|max:450′,
’email’                       => ‘required|email’,
’email’                       => ‘required|email|unique:users’,
‘username’                    => ‘required|min:6|unique:users’,
’email’                       => ‘required|email|unique:users’,
‘password’                    => ‘required|confirmed|min:6’
‘pda’                         => ‘required|unique:forms’,

);

 

Note:- Please replace ` `  to ‘ ‘ before use

How to use date input type in laravel

<link rel=”stylesheet” href=”http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css&#8221; />
<script src=”http://code.jquery.com/jquery-1.8.3.js”></script&gt;
<script src=”http://code.jquery.com/ui/1.9.2/jquery-ui.js”></script&gt;

<script>
var j = jQuery.noConflict();
j(function() {
j( “#datepicker” ).datepicker();
});
</script>

HTML:- <input type=”text” id=”datepicker” />
Laravel:- {{Form::text(‘dob’, null,array(‘placeholder’ => ’01/04/1990′, ‘size’ => 70,  ‘id’ =>’datepicker’))}}

Note:- Please replace ` ` to ‘ ‘ before use