Posts

Showing posts from September, 2019

dependent dropdown in laravel

form < div class ="col-sm-3 p-t-20" > < label for ="Category" >Category</ label > < select class ="form-control" name ="ch_Category" id ="ch_Category" > < option value ="" >Select Category</ option > @foreach( $objProCat as $cat ) < option value =" {{ $cat -> id }} " >{{ ucwords ( $cat -> name ) }}</ option > @endforeach </ select > </ div > < div class ="col-sm-3 p-t-20" > < label for ="subCategory" >Sub Category</ label > < select class ="form-control" name ="ch_subCategory" id ="ch_subCategory" > < option value ="" class ="cat-0" >Select Sub Category</ option > @foreach( $objProSubCat as $cat ) < option value =" {{ $cat ->...

javascript form validation in laravel

< script src= "http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js" ></ script > < script > if ( $ ( "#crate-user" ). length > 0 ) { $ ( "#crate-user" ). validate ({ rules : { name : { required : true , }, email : { required : true , email : true , }, password : { required : true , }, company : { required : true , }, address : { required : true }, city : { required : true , }, state : { required : true , }, country : { required : true , }, ...

How to hide option from select using jquery or javascript

example <select id="members" > <option value="">Select</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> onclick function Display Only One Option function myFunction(user_id) { var memberID = ''; $("#members option").each(function(){ if($(this).val() != null && $(this).val() != '') { memberID = $(this).val(); if (memberID != user_id) { $('#members').children('option[value="'+ memberID +'"]').css('display','none'); } else { $('#members').children('option[value="'+ memberID +'"]').css('display','block'); } }...

How to get all options of a select using jQuery?

How can I get all the options of a select through jQuery by passing on its ID? I am only looking to get their values, not the text. $ ( "#id option" ). each ( function () { // Add $(this).val() to your list }); example <select id="members" > <option value="">Select</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> var memberID = ''; $("#members option").each(function() { if($(this).val() != null && $(this).val() != '') { memberID = $(this).val(); } });

Custom laravel validation message

Controller file /* $this->validate($request, [ 'staples_range' => 'required', ]); */ If you use  $this->validate()  simplest one, then you should write code something like this.. // using this $rules = [ 'staples_range' => 'required' ]; $customMessages = [ 'required' => 'The :attribute field is required.' ]; $this->validate($request, $rules, $customMessages); view file < textarea name ="staples_range" class ="form-control" cols ="40" rows ="box" value =" {{ old( 'staples_range' ) }} " ></ textarea > @if ( $errors ->has( 'staples_range' ) ) < span class ="help-block alert-danger" > < strong > {{ $errors ->first( 'staples_range' ) }} </ strong > </ span > @endif

User will not be allowed to enter more than 4 digits and onKeyPress allowed only number/decimal

example <input type="number" pattern="/^-?\d+\.?\d*$/" onKeyPress="if(this.value.length==4) return false;" /> Allowed  Only Number and Set Max Length Note : If  Decimal Number Allowed  Change Perimeter true  onkeypress = 'return isNumberKey(event, true ,this.value)' second example <input type='number' class='qty' name='' value='' min='0' max='99' onkeypress='return isNumberKey(event, false, this.value)' /> function function isNumberKey(evt, decimal , value){ if(value.length==2){ return false; } var charCode = (evt.which) ? evt.which : evt.keyCode if (decimal == true && charCode == 46) return true; if (charCode > 31 && ((charCode < 48 || charCode > 57) || (charCode >= 96 && charCode <= 105))) return false; return true; }