Computer Forums

Computer Forums (http://www.geekboards.com/forums/index.php)
-   Building Websites (http://www.geekboards.com/forums/forumdisplay.php?f=3)
-   -   Free JavaSccript codes (http://www.geekboards.com/forums/showthread.php?t=14792)

JavaScriptBank 02-13-2010 11:44 AM

Free JavaSccript codes
 
JavaScript codes for Web DEV

HTML to Entities script

This JavaScript converts special HTML characters to their entities version inside user entered data such as a TEXTAREA before the detail at JavaScriptBank.com - 2.000+ free JavaScript codes


How to setup

Step 1: Use JavaScript code below to setup the script
JavaScript
Code:

<SCRIPT type=text/javascript>

// HTML to Entities (form) script- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use

function html2entities(){
var re=/[(<>"'&]/g
for (i=0; i<arguments.length; i++)
arguments[i].value=arguments[i].value.replace(re, function(m){return replacechar(m)})
}

function replacechar(match){
if (match=="<")
return "&lt;"
else if (match==">")
return "&gt;"
else if (match=="\"")
return "&quot;"
else if (match=="'")
return "'"
else if (match=="&")
return "&amp;"
}


</SCRIPT>
        <!--
            This script downloaded from www.JavaScriptBank.com
            Come to view and download over 2000+ free javascript at www.JavaScriptBank.com
        -->

Step 2: Place HTML below in your BODY section
HTML
Code:

<FORM><TEXTAREA style="WIDTH: 400px; HEIGHT: 100px" name=data1></TEXTAREA><BR>
<INPUT onclick=html2entities(this.form.data1) type=button value="Convert special chars to entities">
</FORM>
        <!--
            This script downloaded from www.JavaScriptBank.com
            Come to view and download over 2000+ free javascript at www.JavaScriptBank.com
        -->






JavaScript Spotlight - JavaScript Validate E-Mail - AJAX Page Content Loader
Quote:

Originally Posted by Copyright
The Site may provide, or third parties may provide, links to non-JavaScriptBank.com Internet World Wide Web sites or resources. Because JavaScriptBank.com has no control over such sites and resources, you acknowledge and agree that JavaScriptBank.com is not responsible for the availability of such external sites or resources, and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. You further acknowledge and agree that JavaScriptBank.com shall not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or in connection with use of or reliance on any such content, goods or services available on or through any such site or resource.



All times are GMT -5. The time now is 01:32 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
HTML Help provided by HTML Help Central.