Hi,

I need to implement Insufficient Data Validation on fields.

For example: special characters checking, numbers checking etc

How can I do it? Please help

Regards

Comments

Ank.g9’s picture

By using hook_form_alter you can add your validation function on your desired form.

function your_module_name_form_alter(&$form, &$form_state, $form_id ){ 
	if ($form_id == "your_form_id"){
		$form['#validate'][] = your_validation_function_name;
	}
}

function your_validation_function_name($form, $form_state){

$form_state['values']['your_field_machine_name'];
// here you can check your data validation
}

shajiuddinse’s picture

Thanks for reply,

Please tell me name of file where I have to do make changes

and I need to check realistic data from field

for example if I am putting on last name field '& & $ $ ** @@' then these kinds of special character remove from field automatically

Please help

Ank.g9’s picture

You would need to create a custom module and would need to copy the above maintained code in its .module file. You can change the code as per your need so that it filters the submitted value.

shajiuddinse’s picture

Thanks for reply.

Please tell a resource/example to do this as I am not understanding with your sayings

Regards

Ank.g9’s picture

You can follow giving link steps to create your custom module
http://drupal.org/node/416986

g089h515r806’s picture

If you use Drupal 7, there is a field validation module which could solve such issue:
http://drupal.org/project/field_validation

Chinese drupal tutorials Think in Drupal