parti da qui:

codice:
<html>
<head>
<script language="javascript">
function formatta() {
contenuto = document.forms[0].testo.value;
contenuto = contenuto.replace("[b]", "[b]");
contenuto = contenuto.replace("[\/b]", "<\/b>");
document.getElementById('preview').innerHTML=contenuto;
}
</script>
</head>
<body>
<form name="mioform">
<textarea name="testo" onkeyup="formatta();">
</textarea>
</form>
<div id="preview">
</div>
</body>
</html>