Filed under: Dhtml, Javascript | Tagged: Javascript, print.printing html | Leave a Comment »
changing input type dynamically
the code is in js 1. var input=document.getElementById(id); 2. var input2= input.cloneNode(false); 3. input2.type=’password’; 4. input.parentNode.replaceChild(input2,input);
Filed under: Javascript | Tagged: change input type, input type | Leave a Comment »
Passes parameter to and from popup and parent page
//—-we e in popup window and wanna to show some value from parent window as a preview in popup document.popupfrm.showDiv.innerHTML=window.opener. forms.fieldname.value;
Filed under: Javascript | Tagged: javascript popup pass value, pass value to popup, popup | Leave a Comment »
validating field in fckeditor using javascript
var EditorInstance = FCKeditorAPI.GetInstance(‘message’) ; //message is name of field to be validate if(EditorInstance.EditorDocument.body.innerText.length<=0) { alert(“This firld is mandatory”); EditorInstance.EditorDocument.body.focus(); return false; }
Filed under: Javascript | Tagged: fckeditor blank field validate, fckeditor validate, javascript fckeditor | 1 Comment »
Automatic scroll down div content
function scrollToBottomOfdiv(divID) { mydiv = document.getElementById(divID); mydiv.scrollTop = mydiv.scrollHeight; }
Filed under: Javascript | Tagged: automatic scroll, scroll div, scroll down | 2 Comments »
Check all Checkboxes
<script type=”text/javascript”> function checkAll(fieldName, val) { var chkarr = document.getElementsByName(fieldName); for(r=0;r<chkarr.length;r++) { if (val == true) chkarr[r].checked = true; else chkarr[r].checked = false; } } </script> Check All Mango Banana Apple
Filed under: Javascript | Tagged: cheking all checkbox, select all checkbox | Leave a Comment »
Date validation in javacript
validate date format e.g. 12-2-2004,12-11-08 function validateDate() { obj=//name of your object msg=//your mesage comes here var validNum = /^([0-9]{1,2})-([0-9]{1,2})-([0-9]{2,4})$/; if (validNum.test(obj.value) == false) { alert(msg); obj.focus(); //obj.select(); return false; } return true; }
Filed under: Javascript | Tagged: date check, date validation | Leave a Comment »
Validation of Url
function validateUrl() { obj=document.getElementById(‘txtUrl’); msg=”Enter valid url”; var urlStr = /^\http\:\/\/[a-zA-Z]{3,}\.[a-zA-Z0-9]{2,} (\.[a-zA-Z]{2,3}|\.[a-zA-Z]{2,3}\.[a-zA-Z]{2})$/; if (urlStr.test(obj.value) == false) { alert(msg); obj.focus(); obj.select(); return false; } return true; }
Filed under: Javascript | Tagged: javascript validation, url validation | Leave a Comment »
Email validation using javascript
function validateEmail() { //name of email input field obj=document.getElementById(‘txtEmail’); msg=”Please enter valid email address”; var emailStr = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z] [a-zA-Z\.]*[a-zA-Z]$/; if (emailStr.test(obj.value) == false) { alert(msg); obj.focus(); obj.select(); return false; } return true; }
Filed under: Javascript | Tagged: email validation js, form validation | 2 Comments »
phone no validation using js
function validatePhone(obj,msg) { var validNum =/^[\(]?(\d{0,3})[\)]?[\s]?[\-]?(\d{3})[\s]?[\-]?(\d{4})[\s]?[x]?(\d*)$/; if (validNum.test(obj.value) == false) { alert(msg); obj.focus(); obj.select(); return false; } return true; }
Filed under: Javascript | Tagged: Javascript, regular expression | Leave a Comment »