Showing posts with label Jquery. Show all posts
Showing posts with label Jquery. Show all posts

Monday, 16 July 2012

How to prevent cut, copy and paste into text field useing jquery?

Hellos,

Please write down following javascript:

<script type="text/javascript">
  $(document).ready(function(){
    $('#textField1').bind("cut copy paste",function(e) {
      e.preventDefault();
    });
   });
</script>

Cheers!

Friday, 25 May 2012

How to check checkbox is checked or not using jquery?

Hi All,

Please use the following code:

How to check checkbox is checked or not using jquery?
function validateMultipleCheck(formId){
    if(formId == undefined){
        var totalInput = $('input:checkbox').length;
    }else{
        var totalInput = $('#'+formId+' input:checkbox').length;
    }
    var checkedValues = '';
    if(totalInput > 0){
        $(":input:checkbox:checked").each(function(){
            checkedValues = checkedValues + ',' + this.value;
        })
    }
    return checkedValues;
}

var values = validateMultipleCheck();
alert(values);


Cheers!

How to check radio button selected or not using jquery?

Folks,

Use the following code:

function validateMultipleRadio(formId){
        if(formId == undefined){
            var totalInput = $('input:radio').length;
        }else{
            var totalInput = $('#'+formId+' input:radio').length;
        }
        var checkedValues = '';
        if(totalInput > 0){
            $(":input:radio:checked").each(function(){
                checkedValues = checkedValues + ',' + this.value;
            })
        }
        return checkedValues;

}

var checkValues = validateMultipleRadio('frm');
alert(checkValues);



Cheers!

Tuesday, 7 February 2012

How to check two dates in javascript?

Hi Folks,

      /* Getting current year */
    var current_date = new Date();
      /* Converting user input date of birth to javascript data format... */
      var date_of_birth = new Date($('#order_date_of_birth_year').val(),$('#order_date_of_birth_month').val()-1,$('#order_date_of_birth_day').val());
      if(date_of_birth.getTime()>current_date.getTime()) {
        $('#date_of_birth_error').html("Date of Birth cannot be a future date");
        err = err+1;
        return false;
      }else {
          $('#date_of_birth_error').html(" ");
      }

Cheers!

Wednesday, 21 September 2011

How to change color on focus of input box using jquery?

Hi Dear,

<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
.focused {
    background: #abcdef;
}
</style>
<form name="focusForm" id="focusForm" method="POST" >
<table width="100%" cellspacing="2" cellpadding="2" >
    <tr>
        <td width="180">First Name: </td>
        <td><input type="text" name="txtFName" value="" /></td>
    </tr>
    <tr>
        <td>Last Name: </td>
        <td><input type="text" name="txtLName" value="" /></td>
    </tr>
    <tr>
        <td>Age: </td>
        <td><input type="text" name="txtAge" value="" /></td>
    </tr>
    <tr>
        <td>Occupation: </td>
        <td><input type="text" name="txtOccupation" value="" /></td>
    </tr>
    <tr>
        <td>Secret Question: </td>
        <td><input type="text" name="txtQuestion" value="" /></td>
    </tr>
    <tr>
        <td>Answer: </td>
        <td><input type="text" name="txtAnswer" value="" /></td>
    </tr>
</table>
</form>
<script>
//$("#focusForm input:first").focus();
//$("#focusForm :input").attr('disabled','disabled');
$("#focusForm :input").live("focus blur", function(e) {
    var el = $(this);
    el.toggleClass("focused", el.is(":focus"));
});
</script>

Cheers!

Tuesday, 20 September 2011

How to check all checkbox using jquery?

Hi Guys!

include jquery.js on the top of file and then write following code:

<form name="frm" id="frm" >
<input type="checkbox" name="abc[]" id="1" value="1" >Yes
<input type="checkbox" name="abc[]" id="2" value="2" >No
<input type="checkbox" name="abc[]" id="3" value="3" >None
<input type="button" name="btnCheckAll" value="Check All" onclick="checkAll();" />
</form>
<script>
function checkAll(){
$("#frm input[@name='abc'][type='checkbox']").attr('checked', true);
}

Cheers!

Tuesday, 2 August 2011

How to block mouse right click using javascript?

Guys,

Do the following to block right click:

<script>
$(document).ready(function()
    {
          $(document).bind("contextmenu",function(e){
                  return false;
          });
    });
</script>

Cheers!

Friday, 25 June 2010

How to check session is exit or not using ajax call with jquery?

Hey fox please do the below mentioned code to check it out whether session is exist or not via ajax call:


Write down the following code while call ajax;

function callAjax()
    {
        $.ajax({       
               data: { fname: 'ashwani kumar' },             
              type: 'POST',
                  url: 'ajax.php',
                success: function(data) {
                    alert('success');
                    $('#content').html(data);           
                 },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                     //alert(XMLHttpRequest.status);
                    if (XMLHttpRequest.status === 500) {
                      location.href = 'index.php';
                    }
                  }
            });
    }

IN ajax.php file on top of the page write down the following code in your script:

if(!isset($_SESSION['name']))
{
    header("HTTP/1.0 500 Not Found");
    exit;
}


Cheers!

Monday, 21 June 2010

How to post form using ajax in jquery?

 $.post(url, $("#"+$formname).serialize(),
    function(data){
      $('#content').html(data);
    });

Cheers!

Friday, 26 March 2010

How to use ajax call using jquery?

Please use the following code to call ajax:  
 
function updateStatus() {
     $.ajax({
         url: 'getStatus.php',
         success: function(response) {
             // update status element
             $('#status').html(response);
         }
     });
 }
 
 
 
Cheers!

How do I disable/enable an element?

You can disable/enable an element by setting the 'disabled' attribute to 'disabled' (to disable it) or "" (to enable it). The result of which looks something like this:

// Disable #divID
$("#divID").attr("disabled","disabled");
 
// Enable #divID
$("#divID").removeAttr("disabled");
Cheers!

How do I determine the state of a toggled element?

You can check the state using the :visible or :hidden selectors.

var isVisible = $('#myDiv').is(':visible');
var isHidden = $('#myDiv').is(':hidden');
 
 
Here is() function is used to check whether  div is visible or not.
Cheers!

How do test whether an element exists or not?

You can use the length() function of the jQuery:

if( $('#myDiv').length > 0 )
  $('#myDiv').show();


Cheers!

How to give effect using jquery?

<div id="divId">
           <a href="javascript:void(0);" class="red">Ashwani Kumar</a>

 </div>
<script>
$("#divId").hide("slow");
$("#divId").slow("slow");
$("#divId").toggle("slow");
</script>

Cheers!

How to change CSS using jquery?

<style>
a.red{
color:RED;
}
a.blue{
color:BLUE;
font-weight:bold;
}
</style

<div>
       <a href="javascript:void(0);" class="red">Ashwani Kumar</a>
</div>

$(document).ready(function(){
    $("a").click(function(event)
    {
        $("a").addClass('BLUE');
    }
    )
}
)

Cheers!

How code run after doucment loaded properly?

 
$(document).ready(function(){
   // Your code here
 });
$(document).ready(function() {
$("a").click(function(event){
     alert("Thanks for visiting!");
   });
}); 
This function will work until or unless page will be loaded properly.

How onload functon works in javascript?

Write below code in your page

<script>
window.onload = function(){ alert("welcome"); }
</script>


As soon as page will load, an alert will be popuped with 'welcome' message.

Cheers!

What is jquery?

jQuery is a kind of JavaScript Library.

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
jQuery is designed to change the way that you write JavaScript.