I can give only required and maxlength validation in webform fields , How can i give
alphabets or numbers only validation in webform textfields ??
UPDATE
I used hook like this :-
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'webform_client_form_48') {
if (!preg_match('/^[A-Za-z]+$/', $form['submitted']['name']['#value'])) {
// $form['submitted'][$key]['#attributes']['class'] = 'error';
form_set_error('name', t('Please enter alphabets only for Name.'));
}
}
}
this is working . but the order of displaying message is not proper , the first three
message is coming from ajax form validation and fourth one is from the hook , but i need
the fourth message should come first .
hook_form_alter()
, add a validation handler, validate the field. There are dozens and dozens of examples online (and probably on this site). Looks like you won't need to bother though from Krishna's answer