Magento Resource | E-Commerce Generation Explorer

TAG | form

Here is an example for how to add magento form validation to a custom form:

1
2
3
4
5
6
7
8
9
10
<form action="samepage.php" method="post" id="form_to_validate">
<input id="name" name="name" type="text" class="input-text required-entry"/>
<input id="email" name="email" type="text"  class="input-text required-entry validate-email"/>
</form>
 
<script type="text/javascript">
//< ![CDATA[
var form_to_validate = new VarienForm('form_to_validate',true);
//]]>
</script>

Notes:
– For the form to be validate you need to add the appropriate classes to your input fields.
You will notice all of the input fields have one common class name, required-entry.
To find available class names, try going to One page checkout page, where you have checkout form, then simply view source and look for class names next to input, radio select and other fields.
– Also you must add the Javascript code at the bottom of your custom form. It is quite important!

· ·

Magento already had a built-in contact form that can be used for general contacts.

But we can not find this form on the ADMIN => CMS section. So if we want to edit text in that default contact form, we will need to edit back-end file.

If you are a developer, editing your contact form HTML is a piece cake, the path for the file is:
app/design/frontend/default/[yourtheme]/template/contacts/form.phtml

But, if there are cases when you would like to let your client/customer to edit some intro text, phone numbers, edit text behind the form.
(more…)

· ·

Theme Design by devolux.nh2.me