As I Solve

Bulletproof solutions for the savvy developer.

Hijack form action & interact with page using jQuery


To create a widget that takes a user’s input of Postcode, compares it against an array of postcodes, and acts on the page telling the user whether their postcode is valid or not, you can start with the following code:

<div id="MyForm">
<form method="POST" name="info-form">
    <input type="hidden" value="/form-sent" name="returnURL" />
    <label for="First Name">First Name: </label>
    <input type="text" name="First Name" maxlength="40" />
    <label for="Last Name">Last Name: </label>
    <input type="text" name="Last Name" maxlength="80" />
    <label>Enter the below number: </label>
    <input type="hidden" value="701469" id="verifyNumHidden" name="verifyNumHidden" />
    <input type="text" id="enterVerify" name="enterVerify" />
    <div id="verifyNum"></div>
    <input type="submit" value="Submit" name="save" class="cat_button" />
</form>
</div>

And then use the following script:


Leave a Reply