![]() |
Deleting string from input field
I have an input field that ends up having a lot of automated <pre></pre> tags.
Can I delete all of these from the input fields content on page load? and then can i wrap the fields contents in these tags on form submission? basically so the user never has to see them. Thanks, Michael |
RegEx replace. UNTESTED.
string.replace(/\<(\/)*pre\>/g,"") when the page loads (or can be done server-side.. probably easier) On form submit, again, server-side would be best, but you can use JavaScript to add the tags around the value. inputID.value = "<pre>" + inputID.value + "</pre>" |
Quote:
I dont get this, what are all the special characters for? Does it just remove all <pre> and </pre> tags? and for: inputID.value = "<pre>" + inputID.value + "</pre>" could I use $newText = "<pre>"".$oldText."</pre>"; ? Thanks! |
mmm... but will the user be able to edit the input fields once the page has loaded, and are there more than once set of tags per input field?
|
Quote:
Code:
<pre><pre><pre><pre><pre><pre><pre><pre>Testing description field</pre></pre></pre></pre></pre></pre></pre></pre>I need to remove all <pre> and </pre> tags from that field on page load. Then rewrap the submission in <pre></pre> I know how to rewrap but not how to remove :/ Thanks |
Quote:
It _should_ just remove the "<pre>" and "</pre>" tags from the string. As far as $newText and whatnot, that looks like PHP, not JavaScript. |
here's how WolfShade's regex would work on page load:
Code:
<body> |
Quote:
Just to confirm that this would be okay? Code:
<body> |
That should do it. I can never remember if * or ? is "zero or more of the preceeding character", but it's one or the other.
|
Worked like a charm! Thanks :)
|
| All times are GMT +1. The time now is 02:32 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.