Category: javascript
-
Javascipt: how to use nl2br function
In php we have a function to replace nl2br means new line to break format. but when we need this functionality in our javascript code then what we do? We can do by simply manner: function nl2br(value) { return value.replace(/\n, “”); } Above function will return the converted ‘\n’ to ‘‘. But above function has…
-
Javascript: How to check is valid number or not
Numeric validation require in mostly cases when we want that user enter only numeric value in any text field. For example ‘Age’ field. Obviously, age can not be in string format. Above, I have mentioned javascript function to check that entered value is numeric or not. Please enter only numeric value : Tweet This Post
-
Translate english to hindi by google api
Sometimes we need to develop a website with Hindi font. But main problem is how to insert content in Hindi in admin panel. so here is a solution by this admin can enter content in Hindi font. It will work like: When admin type any word like ‘welcm‘ and then type space it will automatically…
-
WordPress: How to use Ajax at front side without using admin-ajax.php
Mostly all wordpress developers write the code to create widgets in admin side. and he use following code: var ajaxurl =”; var data = { action: ‘action_function_name’ }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post(ajaxurl, data, function(response) { alert(response); }); But when he wants to use…
-
Add and Remove HTML elements dynamically with Javascript
Today I have work in magento and work was save multiple dates in an attribute witout entering multiple values in one field. and need to provide multiple text box ( with date icon to select date )where user can select date and submit the form. On the submit time I have to fill all text…
-
Drag and Drop div area with pure javascript – Step 3
My last two posts told to create javascript and html file. This post will tell you last step to drag and drop div are with pure javascript ( without jQuery ). Add below css code to head tags in the index.html file: and create a folder with name images and put your images in this…
-
Drag and Drop div area with pure javascript – Step 2
After reading my previous post Drag and Drop div area with pure javascript – Step 1, you have created javascript file draganddrop.js. Means you can add this javascript file to html page. so create a file index.html file and put below content in the head tag : And put below code inside the body tag:…
-
Drag and Drop div area with pure javascript – Step 1
Today I have to work on drag and drop functionality and I found that on mostly sites it provides using Jquery but I have to develop with pure javascript. so I found best code for it. and this was the solution : First create a file draganddrop.js and put below code in this file: var…
-
show the div area in middle on screen using jquery
If you want to show any div area in the middle on click any link or button then follow these steps: 1. First download and add JQuery js in your file. 2. now create a function If you want to show any div area in the middle on click any link or button then follow…
-
Remove side space in string
Javascript Trim Functions Use the code below to make trim a method of all Strings. These are useful to place in a global Javascript file included by all your pages. String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,””); } String.prototype.ltrim = function() { return this.replace(/^\s+/,””); } String.prototype.rtrim = function() { return this.replace(/\s+$/,””); } // example of using…
-
Javascript Event based on Firefox and IE
In this post I simply showing how to find the cursor position in the window screen. When user click on this button an event fired and it shows the position of the cursor. This code is running is both Firefox and IE.. Tweet This Post
-
Changing window.location in IE 6
window.location and window.location.href will support to all browsers but it will not support to IE6. For this I have a solution: Suppose you code is : window.location = “http://naveenos.com/”; // Not working??? // Also this does not working?? window.location.href =”http://naveenos.com/”; Then do this, setTimeout(function() { window.location = “http://naveenos.com/”; }, 0); Tweet This Post
-
Jquery : Benefits, Examples and Free Ebook
What is jQuery? Directly taken from the website of jQuery -” jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages”.It is basically a JavaScript framework for writing huge task of JavaScript with few lines of code. What are…
-
Which is the best JavaScript and Ajax Framework ?
Last time, I had published a poll asking which is the best PHP framework and in that poll Zend Framework stand out itself to be the most popular PHP framework among the PHP developers. This time ,I’ve come up with another Poll and I would you to participate in this POLL “Which is the best…