First I want to clarify that I am new to Drupal. So please excuse me If my question is naive.

I have installed the Client Side module in Drupal and it is working fine for all the required fields. I have built a custom form using Drupal form API. Now I want to add some custom rules to some of the fields on the from. I have searched on the internet and found this https://drupal.org/project/fapi_validation and below is the code that I have implemented but this is not working. I think there is some thing that I am missing here. The module name is instructor_registration and I have written this code in instructor_registration.module file.

function instructor_registration_fapi_validation_rules() {

return array(
    'select_required' => array(
        'callback' => 'validation_rule_select_required',
        'error_msg' => 'Please select %field',

function validation_rule_select_required($value) {
if ($value == '0') {
    return FALSE;
else {
    return TRUE;

In the form element I am calling this as :

'#rules' => array('select_required'),

If there is any other information required from my side then please let me know.


Finally found the solution. Actually the code that I was writing was not complete. The examples for adding custom rules in client side validation can found at https://drupal.org/node/1324772 . Hope this helps some one.


| improve this answer | |
  • Would you mind sharing the code... I found the tutorial a bit difficult to follow... – Fazeela Abu Zohra Dec 28 '15 at 8:17
  • Sorry but I don't have the code. – Anshuman Jasrotia Dec 28 '15 at 10:45
  • Successfully I've created a custom rule :) – Fazeela Abu Zohra Dec 28 '15 at 11:03
  • That is good to hear. Cheers – Anshuman Jasrotia Dec 28 '15 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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