Tag Archives: JavaScript
Removing All Spaces From a String Using Javascript
Here is a simple regular expression trick to remove all the spaces from a string using javascript: str = str.replace(/\s+/g,”); // where str is your original string Keep checking for… Read more
Identify the points of diagonal of a rectangle
This JavaScript will find the points of diagonal of a rectangle and draw a line on it. // display line between graph function drawLine( Ax, Ay, Bx, By) { Ax… Read more
Exception Handling In Javascript
There are various ways to handle exception in JavaScript. 1. try..catch..finally block function performDivision(x,y) { try { var z = x/y; return z; } catch(ex) { //raise error ex.message }… Read more
Special character validation using JavaScript
Lets say you have a form, and you want to allow only certain special character for user to enter, then you should use special character validation. In my example, i… Read more
Script to populate Country/States using Javascript
Here is the script, few states names might be incorrect. Will correct them as soon as possible //Developers – Lokesh Lal //Vishal Gupta var countrylist = ‘Afghanistan|Albania|Andorra|Argentina|Armenia|Australia|Austria|Azerbaijan|Bahrain|Bangladesh|Belarus|Belgium|Belize|Bhutan|Bolivia|Bosnia 1|Bosnia 2|Brazil|Bulgaria|Cambodia|Canada|Chile|China|Colombia|Croatia|Cyprus 1|Cyprus… Read more
Reading Json in Javascript
To read JSON in JavaScript what all we need is eval operator var t = “{ user : [{name : ‘Lokesh’ , Age : ’26′ },{name : ‘Vishal’ , Age… Read more
Create FaceBook like Search Box
To create Facebook like search box, what all we need is css and JavaScript. Include the reference of JQuery in the page Create four arrays to hold the values of… Read more
Ajax POST method, using xmlhttprequest
To post data using ajax xmlhttp protocol. var request; function createAjax(url,callbackfunction,parameters,method) { try { request = new ActiveXObject(“Microsoft.XMLHTTP”); } catch(e1) { try { request = new ActiveXObject(“Msxml2.XMLHTTP”); } catch(e2) {… Read more
CSS Expressions
We can use CSS expression, to make the styling of an HTML element dynamic. CSS are generally JavaScript driven, that means what ever we write using CSS classes, gets applied… Read more
Ajax with .NET using XMLHttpRequest Object
How to use Ajax with .Net using basic JavaScript method (xmlhttprequest object) Setup a client side method(Javascript) that will initiate the process and a method that will handle the result… Read more
