How to remove white space from TEXTAREA?

function removeTextAreaWhiteSpace() { var myTxtArea = document.getElementById(‘txtQuestion’); myTxtArea.value = myTxtArea.value.replace(/^\s*|\s*$/g, ”); } Call above function “removeTextAreaWhiteSpace()” onfocus event of textarea. e.g. onfocus=”removeTextAreaWhiteSpace()”

Change body background on Page Reference

Call javascruot function on body load event… e.g. ” var totalCount = 5; function Test() { // if (document.body) { // document.body.style.backgroundImage = ‘url(images/slideshow1_1.jpg)’; // } var num = Math.ceil(Math.random() * totalCount); if (num == 1) { //document.bgColor = “Red”; document.body.style.backgroundImage = ‘url(images/slideshow1_1.jpg)’; } else if (num == 2) { //document.bgColor = “Yellow”; document.body.style.backgroundImage = …

JQuery Validations

http://www.position-relative.net/creation/formValidator/ Above link includes all validation. Its so pretty web site look like more pretty. Download: https://github.com/posabsolute/jQuery-Validation-Engine or https://skydrive.live.com/?cid=efc0ec2e2cd761ee&sc=documents&nl=1&uc=1&id=EFC0EC2E2CD761EE%21160#

Get URL Parameters (QueryStrings) using Javascript

Get URL Parameters (QueryStrings) using Javascript Nearly all server-side programming languages have built-in functions to retrieve querystring values of a URL. In web browsers you can access the querystring with client-side JavaScript, but there is no standard way to parse out the name/value pairs. So here is a function to return a parameter you specify. …

Create or Remove HTML controls dynamically using javascript

Download Source code: live.com = create-remove-control.zip Create file input control using javascript function addFileUploadBox() { if (!document.getElementById || !document.createElement) return false; var uploadArea = document.getElementById(“upload-area”); if (!uploadArea) return; var newUploadBox = document.createElement(“input”); // Set up the new input for file uploads newUploadBox.type = “file”; newUploadBox.size = “70”; // The new box needs a name and …

Clear HTML File Input

HTML file … … – javascript function function clearFileInput() { var oldInput = document.getElementById(“fileInput”); var newInput = document.createElement(“input”); newInput.type = “file”; newInput.id = oldInput.id; newInput.name = oldInput.name; newInput.className = oldInput.className; newInput.style.cssText = oldInput.style.cssText; // copy any other relevant attributes oldInput.parentNode.replaceChild(newInput, oldInput); }

Textbox should not contain special character using JavaScript

Call Javascript function on “onkeyup” event of TextBox function valid(field) { var txt = document.getElementById(‘TextBox1′).value; var iChars = “!@$%^&*()+=-[]\\\’;,./{}|\”:?~_”; for (var i = 0; i < txt.length; i++) { if (iChars.indexOf(txt.charAt(i)) != -1) { alert(“Your string has special characters. \nThese are not allowed.”); document.getElementById(‘TextBox1′).value = txt.substring(0, txt.length – 1); return false; } } } function …