I want to replace the characters while typing in the Textarea. But with the following code snippets (nearly 250 lines are there), here I'm using replace() method of RegEx. It checks against the replacement too. I want it should check only the pattern/regexp.
Test
m -> A //ok
M -> B //ok
, -> F //Wrong, should be C
How can I get hte replacement without changing the order of hte line?
<!DOCTYPE html PUBLIC "-//W3C//Dtd HTML 4.0 transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
</head>
<body onload="javascript:formTest.source.focus()">
<script language="javascript" type="text/javascript">
var text;
function startConvert()
{
text = document.formTest.source.value;
text = text.replace(/\u006d/g, "A");
text = text.replace(/M/g, "B");
text = text.replace(/,/g, "C");
text = text.replace(/</g, "D");
text = text.replace(/c/g, "E");
text = text.replace(/C/g, "F");
text = text.replace(/v/g, "G");
text = text.replace(/V/g, "H");
text = text.replace(/I/g, "I");
text = text.replace(/x/g, "J");
text = text.replace(/X/g, "K");
text = text.replace(/xs/g, "L");
text = text.replace(/\//g, "@");
document.formTest.destination.value=text;
}
</script>
<center>
<table width="500" >
<tbody>
<tr>
<form name="formTest">
<td>
<textarea onkeyup="startConvert();"
onclick="startConvert();"
name="source"
rows="5"
onselect="startConvert();">
</textarea>
</td>
<td>
<textarea
name="destination" rows="5"></textarea>
</td>
</form>
</tr>
</tbody>
</table>
</center>
</body>
</html>