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.