Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

BBS: JavaScript 1.2 Challenge - September 03, 1998 at 23:17:56

You are here: irt.org | BBS | JavaScript 1.2 Challenge [This BBS is closed]

Posted by Vijay Jagdale on September 03, 1998 at 23:17:56:

Here is a code to initcap text (That Is Capitalize The Initial
Character Of Each Word). Unfortunately neither MSIE, nor
NetScape recognizes the toUpperCase property for the $1,
$2 properties in the regular expression REPLACE command.

Strange thing is that "$1".sup (), "$1".blink () etc, work fine. Can
anyone figure out a way around this?

Vijay

<XMP>
<HEAD>
<TITLE>Untitled</TITLE>
<SCRIPT LANGUAGE="JavaScript1.2">
function initCap (inp){
re=/ ([A-Za-z]) ([A-Za-z]*)/ig
return inp.replace (re,"$1".toUpperCase () + "$2".toLowerCase ())
}
</SCRIPT>
</HEAD>

<BODY>
<form>Text Input:<textarea name="AAA" cols="60" rows="10">abcdef</textarea>
<p>Text Output:<textarea name="BBB" cols="60" rows="10"></textarea>
<p><input type="Button" value="InitCap" onclick="form.BBB.value=initCap (form.AAA.value)">
</form>
</BODY>
</XMP>

Follow-ups:

You are here: irt.org | BBS | JavaScript 1.2 Challenge [This BBS is closed]

©2018 Martin Webb