Skip to main content
-iop
Source Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

You can create a custom module for that:

  1. webfv.info
  2. webfv.module
  3. webfv.js

Put all these files into a folder called webfv.


This is the webfv.module file:

<?php
function webfv_form_comment_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] == 'webform-client-form-80') {
    $form['#attached']['js'][] = array(
    'data' => drupal_get_path('module', 'webfv') . 'webfv.js', 
    'type' => 'file',
  );
}
}

And this is the webfv.js file:

    (function($) {
      $(document).ready(function() {
      // Put your code here. //
      });
    }) (jQuery);

And of course, you should have a webfv.info file:

name = webfv
description = JavaScript Webform Validation
core = 7.x
files[] = webfv.module

Note: this is just one way of doing it, there are some other ways.

You can create a custom module for that:

  1. webfv.info
  2. webfv.module
  3. webfv.js

Put all these files into a folder called webfv.


This is the webfv.module file:

<?php
function webfv_form_comment_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] == 'webform-client-form-80') {
    $form['#attached']['js'][] = array(
    'data' => drupal_get_path('module', 'webfv') . 'webfv.js', 
    'type' => 'file',
  );
}
}

And this is the webfv.js file:

    (function($) {
      $(document).ready(function() {
      // Put your code here. //
      });
    }) (jQuery);

And of course, you should have a webfv.info file:

name = webfv
description = JavaScript Webform Validation
core = 7.x
files[] = webfv.module

You can create a custom module for that:

  1. webfv.info
  2. webfv.module
  3. webfv.js

Put all these files into a folder called webfv.


This is the webfv.module file:

<?php
function webfv_form_comment_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] == 'webform-client-form-80') {
    $form['#attached']['js'][] = array(
    'data' => drupal_get_path('module', 'webfv') . 'webfv.js', 
    'type' => 'file',
  );
}
}

And this is the webfv.js file:

    (function($) {
      $(document).ready(function() {
      // Put your code here. //
      });
    }) (jQuery);

And of course, you should have a webfv.info file:

name = webfv
description = JavaScript Webform Validation
core = 7.x
files[] = webfv.module

Note: this is just one way of doing it, there are some other ways.

Source Link
herci
  • 2.2k
  • 1
  • 26
  • 58

You can create a custom module for that:

  1. webfv.info
  2. webfv.module
  3. webfv.js

Put all these files into a folder called webfv.


This is the webfv.module file:

<?php
function webfv_form_comment_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] == 'webform-client-form-80') {
    $form['#attached']['js'][] = array(
    'data' => drupal_get_path('module', 'webfv') . 'webfv.js', 
    'type' => 'file',
  );
}
}

And this is the webfv.js file:

    (function($) {
      $(document).ready(function() {
      // Put your code here. //
      });
    }) (jQuery);

And of course, you should have a webfv.info file:

name = webfv
description = JavaScript Webform Validation
core = 7.x
files[] = webfv.module