Wednesday, 5 November 2014

How to disable Ctrl+V (Paste) , Ctrl+X (Cut) and Ctrl+C (Copy) with jQuery?

<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
 $(document).ready(function(){
      $('#read').bind("cut copy paste",function(e) {
   e.preventDefault();
   alert(" 'Ctrl+c & Ctrl+x & Ctrl+v has been disabled' ")
      });
   });
});
</script>
<input type="text" id="read" />

How to disable right click in mouse event in jquery?

<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
 $(document).bind('contextmenu', function (e) {
  e.preventDefault();
  alert('Right Click is not allowed');
 });
});
</script>

Tuesday, 4 November 2014

How to lowercase of input field in onkeyup event?

Script Method:
<input type="text" id="ele" onkeyup="this.value=this.value.toLowerCase()" >
CSS Method:
Add style "text-transform:uppercase"
<input type="text" id="ele" style='text-transform:lowercase' >

Monday, 3 November 2014

How to uppercase of input field in onkeyup event?

Script Method:
<input type="text" id="ele" onkeyup="this.value=this.value.toUpperCase()" >
CSS Method:
Add style "text-transform:uppercase"
<input type="text" id="ele" style='text-transform:uppercase' >

Friday, 24 October 2014

How to get the number of rows in a table - tbodyin jquery?

<table id="myTable" cellpadding="0" cellspacing="0">
  <thead>
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Birth Date</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>John</td>
      <td>Smith</td>
      <td>03-11-1980</td>
    </tr>
  </tbody>
</table>

Solution:
$("#myTable tbody tr").length - Its wrong.
$("#myTable > tbody > tr").length; - Its right to get solution.

Thursday, 16 October 2014

How To Get a Multiple Rows From JSON Object and Append to the Table

$("#table-list tr").detach();
    $.get(url+"payroll/payroll-ajax.php","id="+arg+"&param=view_loan",function(data){
    var objJSON = eval("(function(){return " + data + ";})()");
    var i=objJSON.length;
    for (var j=0;j<i;j++) {
        k=j+1;
        var newRow =
        "<tr>"
        +"<td>"+k+"</td>"
        +"<td>"+objJSON[j].deduction_date+"</td>"
        +"<td>&#2352;  "+objJSON[j].deduction_amt+"</td>"
        +"</tr>" ;
        $(newRow).appendTo("#table-list tbody");
    }
    $('#view-loan-table-modal').modal('toggle');
    var objJSON="";
    });

This above code is used to get multiple rows from json object.

If the variable data is contains following values.

data=[{"id":"3","loan_id":"8","deduction_date":"2014-07-16 12:54:14","deduction_amt":"16667"},{"id":"9","loan_id":"8","deduction_date":"2014-08-12 10:25:36","deduction_amt":"16667"},{"id":"10","loan_id":"8","deduction_date":"2014-08-12 02:22:53","deduction_amt":"16667"}]

This is JSON object value.

The out put is:

Feet/Inches to Meters Converter & Lbs to Kgs Converter

 <!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8" />   <title>Feet/Inches ⇄...