Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts

Wednesday, October 4, 2017

Store data in mysql for all the languages to use character set

 Store data in mysql for all the languages to use character set


HTML HEAD TAG



MYSQL DATABASE CONNECTION

mysql_query('SET character_set_results=utf8');
mysql_query('SET names=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_results=utf8');
mysql_query('SET collation_connection=utf8_general_ci');

Saturday, February 16, 2013

Email Validation With RegExp In Jquery and Javascript

Email Validation With RegExp In Jquery and Javascript

$(document).ready(function() {

   $('#btnSubmit').click(function() {
 
var sEmail = $('#txtEmail').val();
if ($.trim(sEmail).length == 0) {
alert('Please enter valid email address');
e.preventDefault();
}

// example 1
if (validateEmail(sEmail)) {
alert('Invalid Email Address');
e.preventDefault();

} else {
alert('Email is valid');
}
// example 2
if (validate_email(sEmail)) {
alert('Invalid Email Address');
e.preventDefault();

} else {
alert('Email is valid');
}

// example 3
if (IsEmail(sEmail)) {
alert('Invalid Email Address');
e.preventDefault();

} else {
alert('Email is valid');
}
});
});

function validateEmail(sEmail)
{
var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (!filter.test(sEmail)) {
return false;
} else {
return true;
}
}
function validate_email(email)
{
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if (!emailReg.test(email)) {
return false;
} else {
return true;
}
}

function IsEmail(email)
{
var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!regex.test(email)) {
return false;
} else {
return true;
}
}


Thursday, August 25, 2011

Get Values from Checkbox in Jquery

$('#checkBox').attr('checked');

$('#edit-checkbox-id').is(':checked');

var checked = $('input[type=checkbox]').is(':checked');

var checkbox_value = $('#check_box_id:checked').val();

$("input[@type=checkbox][@checked]").each(

function() {
   // Insert code here
   }

);

//
$("input[type=checkbox][checked]").each(

function() {
   // Insert code here
   }
);
$('input[name=foo]').is(':checked')
$('input[name=foo]').attr('checked')
$('input[name=foo]').attr('checked', true);
$('input[name=foo]').attr('checked', false);


$(document).ready(function(){

$('#submit_button').click(function() {

if (!$("input[@name='name']:checked").val()) {
   alert('Nothing is checked!');
   return false;
}

else {
   alert('One of the radio buttons is checked!');
}

});
});

Thursday, July 14, 2011

Div Scrollable Contents on MouseOver On Javascript




SCROLLABLE DIV CONTENTS WHEN MOUSE OVER THE SCROLL UP AND SCROLL DOWN LINKS
SCROLLABLE DIV CONTENTS WHEN MOUSE OVER THE UP AND DOWN LINKS The top-level function, escape, encodes the string that is contained in the string argument to make it portable. A string is considered portable if it can be transmitted across any network to any computer that supports ASCII characters. We can use escape function in JavaScript to make a string portable to transmit it over a network. All the non ASCII characters are to be converted before sending them by using escape function. The escape function will replace these non ASCII characters to its two or four digit hex format.
Scroll Up Scroll Down

Here Code


<html>
<script type="text/javascript">
var scrolling = null;
var _speed = 12;


function doScrollUp()
{
var d = document.getElementById('scroller');
d.scrollTop = d.scrollTop - _speed;


scrolling = window.setTimeout(function() {
doScrollUp();
}, 100);
}


function doScrollDown()
{
var d = document.getElementById('scroller');
d.scrollTop = d.scrollTop + _speed;


scrolling = window.setTimeout(function() {
doScrollDown();
}, 100);
}


function doStopScroll()
{
window.clearTimeout(scrolling);
}
</script>
<body>
<h2>SCROLLABLE DIV CONTENTS WHEN MOUSE OVER THE UP AND DOWN LINKS</h2>
<div id="scroller" style="width:100%; height:100px; overflow:hidden;">


SCROLLABLE DIV CONTENTS WHEN MOUSE OVER THE UP AND DOWN LINKS
<br /><br /><br />
The top-level function, escape, encodes the string that is contained in <br /><br />
the string argument to make it portable. A string is considered portable <br /><br />
if it can be transmitted across any network to any computer that
supports ASCII characters.<br />
We can use escape function in JavaScript to make a string portable
to transmit it over a network. All the non ASCII characters are to be <br />
converted before sending them by using escape function. The escape function <br />
will replace these non ASCII characters to its two or four digit hex format.<br />
<br /><br /><br /><br />
</div>
<div>
<span style="color:red;" onmouseover="doScrollUp();" onmouseout="doStopScroll();" style="padding-right:10px;">Scroll Up</span>
<span style="color:blue;" onmouseover="doScrollDown();" onmouseout="doStopScroll();">Scroll Down</span>
</div>


</body>
</html>

Tuesday, July 12, 2011

Escape Function in Javascript or Jquery

Escape Function:


The escape() function encodes a string.


<script type="text/javascript">
unescape("you can pass & symbols & any other special characters through query string when you using ajax posting & jquery posting");
</script>
The top-level function, escape, encodes the string that is contained in the string argument to make it portable. A string is considered portable if it can be transmitted across any network to any computer that supports ASCII characters.
We can use escape function in JavaScript to make a string portable to transmit it over a network. All the non ASCII characters are to be converted before sending them by using escape function. The escape function will replace these non ASCII characters to its two or four digit hex format.
 The escape function converts a blank space into %20, same way it converts & to %26.



The unescape() function decodes an encoded string.


<script type="text/javascript">
unescape("you%20can%20pass%20&%20symbols &%20any%20other%20special characters%20through%20query%20string when%20you%20using%20ajax%20posting &%20jquery%20posting");
</script>

Saturday, January 15, 2011

Login Screen Shaking

Shaking the Login Screen.  when u can refresh the page and submit the page....

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
          addLoadEvent = function(func){
            if (typeof jQuery!="undefined")
                jQuery(document).ready(func);
           
            else if ( typeof wpOnload!='function'){
                wpOnload=func;
            } else {
                var oldonload=wpOnload;
                wpOnload=function(){
                    oldonload();
                    func();
                }
            }
        };
       
        function s(id,pos){
            g(id).left = pos+'px';
        }
        function g(id){
            return document.getElementById(id).style;
        }
        function shake(id,a,d) {
            c=a.shift();
            s(id,c);
            if(a.length>0){
                setTimeout(function(){
                    shake(id,a,d);
                },d);
            } else {
                try {
                    g(id).position='static';
                    wp_attempt_focus();
                }
                catch(e){}
            }
        }
       
        addLoadEvent(function(){
            var p = new Array(10, 10, 10, 0, -10, -10, -10, 0);
            p = p.concat(p.concat(p));
            var i = document.forms[0].id;g(i).position='relative';
            shake(i, p, 20);
        });
  </script>


</head>
<body onload="document.getElementById('username').focus();">
<table width="90%" cellpadding="0" cellspacing="0" border="0" align="center">
   <tr>
      <td valign="top">
         <form method="post" action="" name="frmLogin" id="frmLogin">
                 <table width="50%" cellpadding="2" cellspacing="2" border="1" align="center">
                         <tr><td height="10px"></td></tr>
                          <tr>
                        <td width="40%"> USERNAME:</td>
                         <td width="60%">
                                 <input type="text" name="username" id="username" autocomplete="off" />
                      </td>
                      </tr>
                       <tr>
                       <td>PASSWORD: </td>
                      <td>
                       <input type="password" name="password" id="password" autocomplete="off" />
                   </td>
               </tr>             </table>
      </form>
  </td>
</tr>
</table>
</body>
</html>
<script type="text/javascript">
    function wp_attempt_focus(){
        setTimeout( function() {
            try {
                d = document.getElementById('username');
                d.value = '';
                d.focus();
            } catch(e){}
        }, 200);
    }
     wp_attempt_focus();
    if(typeof wpOnload == 'function')wpOnload();
  </script>

Thursday, December 2, 2010

Disable Right Click On Web Page Using jQuery

This is code used for disable right click


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

This code for disable right click on web pages. It is working all browsers excepted Opera..
try it..
Download add jQuery File . Here it is link http://jquery.com/

Disable Right Click Easily using jquery


<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>jQuery disable right click</title>
<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" language="javascript">

           $(function() {
             $(this).bind("contextmenu", function(e) {
                    e.preventDefault();
             });
   });
</script>
</head>

<body>
        jQuery disable right Click
</body>
</html>