A text box cannot hold innerHTML. It holds a string value, which could potentially become innerHTML. It would be more standard to create and/or clone nodes to create functional markup from the string entered into a textbox.
That said, the operative information here is that the characters in the text box are the string value of that text box, so you could do:
Code:
var myString = textBox.value.replace(/x/g, '×');
to replace all lower case x characters in the string value to the × entity and store the new string value in the variable myString. All further processing could then be done utilizing the value of myString.
But if there are other lower case x characters that are not intended as × entities, this may be a problem, but the regular expression and replacement:
could be modified in an attempt to prevent this, like:
Code:
/(\d *)x( *\d)/g, '$1×$2'
Which would be ideal for stuff like:
255 x 150
and:
75x22
but would leave stuff like the x in:
exact
alone.
Bookmarks