O'Reilly logo

JavaScript Regular Expressions by Gabriel Manricks, Loiane Groner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Manipulating data

We are going to add one more input to our form, which will be for the user's description. In the description, we will parse for things, such as e-mails, and then create both a plain text and HTML version of the user's description.

The HTML for this form is pretty straightforward; we will be using a standard textbox and give it an appropriate field:

Description: <br />
<textarea id="description_field"></textarea><br />

Next, let's start with the bare scaffold needed to begin processing the form data:

function process_description() { var field = document.getElementById("description_field"); var description = field.value; data.text_description = description; // More Processing Here data.html_description = "<p>" + description + "</p>"; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required