Header Ad

Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Tuesday, April 10, 2012

Disabling RIGHTCLICK using JavaScript - How to disable right click using Java Script


Disabling RIGHTCLICK using JavaScript - How to disable right click using Java Script

Copy & Paste below code into <HEAD></HEAD> of your HTML.


<SCRIPT TYPE="text/javascript"> 
<!-- 

var message="Sorry, right-click has been disabled"; 

/////////////////////////////////// 
function clickIE() {
if (document.all) {
(message);
return false;
}
}

function clickNS(e) { 
if (document.layers||(document.getElementById&&!document.all)) { 
if (e.which==2||e.which==3) {
(message);
return false;
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS;
else{
document.onmouseup=clickNS;
document.oncontextmenu=clickIE;
document.oncontextmenu=new Function("return false") 
// --> 
</SCRIPT>

Wednesday, April 4, 2012

How to read JSON data using Java


This article will help how to read JSON using java program. By using "JSON-lib" library we can read JSON data.

The following link will provide a detailed explanation about how to use "JSON-lib"

Thank you.

Tuesday, April 3, 2012

Introduction to JSON


JSON( Java Script Object Notation) is a lightweight data interchange format. It is easy to parse and generate. JSON format is completely language independent. But uses conventions that is easy for programmers.

JSON is built on two structures:
  • A collection of name/value pairs.
  • An ordered list of values. Like an array, List, or sequence.

The following sample JSON format. We can easily retrieve the values of below JSON by using keys.
{
      "id": 1,
      "name": "John",
      "designation": "SE"
}

The following is the sample example for LIST of values.

{
  "employees":
  [
    {
      "id": 1,
      "name": "John",
      "designation": "SE"
    },
    {
      "id": 2,
      "name": "Smith",
      "designation": "SE"
    }
  ]
}

Friday, April 23, 2010

Java Script Regular Expressions

The following are the some of the java script regular expressions.

var Integer =/^[\-]?\d*$/;
var PositiveInteger =/^\d*$/;
var RealNumber = /^[\-]?\d*$|^[\-]?\d*\.\d*$/;
var PositiveRealNumber = /^\d*$|^\d*\.\d*$/;
var Currency = /^[\-]?[\$]?[\-]?\d+$|^[\-]?[\$]?[\-]?\d+\.\d*$|^[\-]?[\$]?[\-]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var Currency$ = /^[\-]?[\$]?[\-]?\d*$|^[\-]?[\$]?[\-]?\d*\.\d*$|^[\-]?[\$]?[\-]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var PositiveCurrency = /^[\$]?\d*$|^[\$]?\d*\.\d*$|^[\$]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var PositiveCurrency$ = /^[\$]?\d*$|^[\$]?\d*\.\d*$|^[\$]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var GeneralNumber = /^\d*$|^\d*\.\d*$/;
var FixedNumber = /^\d*\.\d*$/;
var StandardNumber = /^\d{1,3}(,\d{3})*\.\d{2}$/;
var Percentage = /^\d*$|\d{1,3}(,\d{3})*\.\d{1,3}[\%]?/;
var Alphabet = /^\b[a-z\s\.]*$/i
var Address = /./
var CreditCardNo = /^[0-9]{16}$/;
var AlphaNumeric = /^[a-z_0-9\s]*$/i
var Phone = /^\d{10}$|^\d{3}\-\d{3}\-\d{4}$/;
var LongPhoneFormat = /^\d{10}$|^[\(]?\d{3}[\)]?[\-\s]*\d{3}[\-\s]?\d{4}$/;
var StandardPhoneFormat = /^\d{10}$|^\d{3}[\-\s]{1,2}\d{3}[\-\s]?\d{4}$/;
var ZipCode1 = /^[0-9]{5}$/;
var ZipCode2 = /^[0-9]{4}$/;
var Email = /^[a-z_0-9]?[a-z_0-9\.\-\']+@[a-z_0-9\.\-]+\.[a-z_0-9]{2,3}$/i
var MultiEmail =/^[a-z_0-9\@\.\,\;\:\#\']$/i
var SSN = /^\d{3}[\-\s]*\d{2}[\-\s]*\d{4}$/;
var DateOfBirth=/^\d{2}[\\\s]*\d{2}[\\\s]*\d{4}$/;
var urlPattern = /^(?:(?:ftp|https?):\/\/)?(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z])\b(?:\d+)?(?:\/[^<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^<>()\[\]{}\s\x7f-\xff]+)*)?/;