Javascript validation to allow the only numeric value in the text field.

How to set the validation to allow only numeric value in the HTML text field using JAVASCRIPT. We can set the validation using window keycode event on JAVASCRIPT. Like we want to allow the user only able to enter the numeric value in the text field just we need to set JAVASCRIPT function called on KeyPress like below.

Continue reading Javascript validation to allow the only numeric value in the text field.

Laravel create excel file directly from blade view using Laravel Excel Maatwebsite

Laravel create the excel file directly from the blade view HTML table. It’s too easy and the fastest way to generate excel file from HTML table. Without blade view file we need to create the code for the generating the excel file. We need to set the array to the proper column format for generating the excel sheet. Now, forget all those things and just create the table on the Laravel blade view file.

Continue reading Laravel create excel file directly from blade view using Laravel Excel Maatwebsite

WordPress – Disable HTML in comment

How we can disable HTML tag on WordPress comment using Hook. If HTML tags are enabled Hackers enter javascript code on the comment and hack the WordPress. If you are used the WordPress for blogging you must disable the HTML code from the comment after installing the WordPress.

Continue reading WordPress – Disable HTML in comment

CSS Counter increment

How to create the counter increment using CSS like the bullet. CSS provides the counter functionality using that we can create the number before stating lists as per line like the bullet number.

Let’s create the HTML code for our counter.

<div class="lists">
<p>First Element</p>
<p>Second Element</p>
<p>Third Element</p>
<p>Four Element</p>
<p>Five Element</p>
<p>Six Element</p>
<p>Seven Element</p>
</div>

Let’s creat the counter code for our listing using CSS.


<style type="text/css">
.lists {
counter-reset: headings;
list-style: none;
}
.lists > p:before {
background: none repeat scroll 0 0 #8F8888;
border-radius: 15px;
color: #FFFFFF;
counter-increment: headings;
content: counter(headings, decimal);
display: block;
float: left;
font-size: 16px;
font-weight: bold;
height: 25px;
line-height: 26px;
margin-bottom: 0;
margin-right: 5px;
top : -5px;
position: relative;
text-indent: 8px;
width: 25px;
}
</style>

Using above code you can create the listing counter on any  HTML tag listing like above. The output look like below.

CSS Counter

If you have any issue or question write comment below.

AdminLte active current menu using JAVASCRIPT

AdminLte is the most popular and open source admin theme. many developers used AdminLte for developing admin panel. Many Developers use PHP if condition for active the current sidebar menu. It’s hard to manage with if condition when we have many sidebar menus.

I think we should use JAVASCRIPT for active the current menu for the sidebar. it’s too easy and simple js snippets.

$(document).ready(function(){

    var url = window.location;
    // Will only work if string in href matches with location
    $('ul.nav a[href="'+ url +'"]').parent().addClass('active');

    // Will also work for relative and absolute hrefs
    $('ul.nav a').filter(function() {
        return this.href == url;
    }).parent().addClass('active');
});

Just add above code into your javascript file. then checked the “active” class is add onto your current menu.

How to remove html tags from string using PHP

How to remove HTML tags from string programmatically. let’s see the two easy way to remove HTML tags from the string using “strip_tags” and “preg_replace”. So let’s see how to remove HTML code from the string using “strip_tags”.

$string = strip_tags(“Hello <b>world!</b>);

We used the ‘strip_tags’ function for removing the HTML tags from the string. so it’s very easy to remove HTML using “strip_tags”. But the “strip_tags” add space after removing the tags from the string like.

$string = strip_tags(“Hello<b>world!</b>);

The output of the above statement is “Hello world!” instead of “Helloworld!”. so let’s see the another trick for removing only HTML tags without adding the space.

$string = preg_replace(#<[^>]+>#’, ‘ ‘, ‘Hello<b>world!</b>’);

The output of the above function is “Helloworld!” instead of “Hello world!”.

If you face any issue after using this code please write a comment below.