Question: Heres the scenario - using asp.net MVC with jquery mobile - newbie on both

Problem: Back button sends a **GET** to a page that was created with a **POST**

Scenario:

1. Page 1 has a searchbox and submit button - clck submit does **POST** to page 2.
2. Page 2 has list of serch result links, click a search result, go to page 3
3. Click back button on page 3, and it sends a **GET** to page 2.

Tried on Safari and Firefox. Firebug showing a GET on the back button.

Is this common? How would you deal with this?

A) When submitting form, somehow add the textbox to the URL (sounds tricky)

B) Mark the search page action with both HTTPPost and HTTPGet? Then save the search text in a session or somewhere?

C) Is there a better option?

Any advice appreciated!

Answer: 
Use the built-in `rules()` method to add rules and assign them by `class`. [See documentation.](http://docs.jquery.com/Plugins/Validation/rules#.22add.22rules)

Note: You **must** call this method *after* you call `.validate()`.

I have a very large form where the user can dynamically add fields. This is the exact method I use to make sure my newly created fields are also part of the validation.

(If you remove the `class` from the `input`, it will **not** (can not) validate on the `name` attribute because the `name` attribute is not used anywhere within the `.validate()` options or rules.)

**HTML:**

```
<form id="form">
    <input type="text" class="myclass" name="whatever" />
</form>

```

**jQuery:**

```
$("#form").validate({
    // my options
});

// the following method must come AFTER .validate()
$('#form').find('.myclass').each(function() {
    $(this).rules('add', {
        required: true,
        minlength: 5,
        messages: {
            required: "Required input",
            minlength: jQuery.format("At least {0} characters are necessary")
        }
    });
});

```

[**jsFiddle DEMO**](http://jsfiddle.net/kSFKE/)
1. Simply download the source, e.g., <http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.js>, and then,
2. Do a search replace for the word `name` and replace it with another attribute, like `validate_on`
3. Use that new source in place of the old one.