Skip to main content

Posts

Dynamic control generation - Javascript code

The JS code for generating controls dynamically. Copy and paste the code and save it as an HTML file, take it on the browser to know the working of the script. The add Ctrl function will duplicate the TR of the table. On clicking the link "Add More Contact Persons" the new row of control will be created. On clicking the " Remove" link the corresponding row will be deleted.

JS function to convert string to US phone number format

Javascript function to change the string to US telephone number format Eg: if input string is 0115463234 ,it will be converted to (011)546-3234 function toPhoneFormat( obj ){ val=document.getElementById(obj).value; arrChars=val.split(''); formatedString=''; for(i=0;i < val.length;i++){ if(i==0) formatedString+='('; if(i==3) formatedString+=') '; if(i==6) formatedString+='-'; formatedString+=arrChars[i]; } document.getElementById(obj).value=formatedString; } Sample usage: Function is called in the onBlur event <input id="txtpersontel" type="text" name="persontel" maxlength="20" style="width:125px" onblur="toPhoneFormat('txtpersontel')" > Tweet

JS Function to check whether the string is numeric

Javascript function to check the string in the textbox is numeric function name : isNumber parameters : Input control object and flag to allow decimal points Function doesn't allow non numeric characters in the control the function can be called on onKeyUp event of the control. if permitDecimal = 0 then decimal point '.' is not allowed in string, else dot is allowed. function isNumber( obj ,permitDecimal ){ var val = document.getElementById(obj).value ; var te=val.match(/\d+\.?\d*/); document.getElementById(obj).value=te; val=te; if(val!=""){ if( isNaN(val) ){ endOFString=val.length-1; val=val.substring(0,endOFString); } if(!permitDecimal){ if(val){ val=val.toString(); document.getElementById(obj).value=val.replace(/\./g,''); } }else{ document.getElementById(obj).value=val; } } } Sample usage <input id="txtpersontel" type="text" name="persontel" maxlength="20" style=...

PHP function to remove all character which are not alphabets or numbers

Here is the php function to remove all character which are not alphabets or numbers to remove the white space just pass the param $removeSpace as 1 function removeNonAlphaNumero( $str , $removeSpace = 0 ){ $return_string = ""; if( trim($str) != "" ){ if($removeSpace ) $return_string = preg_replace("/[^a-zA-Z0-9]/", "", $str); else $return_string = preg_replace("/[^a-zA-Z0-9\s]/", "", $str); } return $return_string; }

What is Bandwidth Stealing - Direct linking - Hot linking?

What is Bandwidth Stealing / Direct linking / Hot linking? Simple way to explain "Bandwidth Stealing" is, Suppose you are displaying website images or icons hosted on some other's server with out their permission on your blog/ website, then it is a Bandwidth theft and you are stealing their bandwidth. The owner of that website is paying for bandwidth of the site from where you linked an image.


Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »
Member
Search This Blog