Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I am looking to run javascript for a textbox on a webform. So i am looking to add an extra attribute to my webform. but I am not sure how the webform is rendered . I was able to do that for my cck form using hook form alter but unable to do that for a webform.

Simply I have

<input type="text" maxlength="128" name="submitted[school_name_cancer]" id="edit-submitted-school-name-cancer" size="32" value="" class="form-text required" />

But I would like

Thanks.

share|improve this question

1 Answer

up vote 1 down vote accepted

see this Form API Quickstart Guide http://drupal.org/node/751826 to review how to build forms, know how a form is builded:

The Drupal Form API provides sophisticated form techniques and also allows for almost unlimited possibilities for custom theming, validation, and execution of forms. Even better, ANY form (even those in core) can be altered in almost any way imaginable--elements can be removed, added, and rearranged.

if your javascript is for validate fields of your form, I guess that this answer (related with validations of fields) could be useful How do I create custom content types in drupal?

share|improve this answer
Hi,I was able to do this with a form but I am unable to add custom attribute to a webform element Its hard to know its how it is being referred or the form is being drawn. – pal4life Oct 2 '11 at 19:23
do you refer a form builded using WebForm module drupal.org/project/webform ? – moon.watcher Oct 2 '11 at 19:37
regarding webforms you can review this post about how alter forms of webform module: drupal.org/node/454066 – moon.watcher Oct 2 '11 at 19:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.