w2form.get

Finds and returns the field object or its index.
get([field], [returnIndex])
field string, name of the field (optional)
returnIndex boolean, if true returns index in the fields array (optional)
Returns object, integer, or null.

Description

This method will find the field object in the .fields array and return it or its index. If the field does not exists it will return null. Because JavaScript passes objects by reference, modifying this object will modify the original field. If the second optional argument returnIndex is set to true, the method will return index of the field in the .fields array.
If you call .get without any arguments, it will return you an array of all field names.
If you have form defined in the following way: You can do:

User Comments

comments powered by Disqus