Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // http://www.gravityhelp.com/forums/topic/name-field-1#post-169715
- // change the 350 here to your form ID
- add_filter('gform_validation_350', 'force_alpha_name', 10, 2);
- function force_alpha_name($validation_result){
- $form = $validation_result['form'];
- // In my form, the name input is field 1, so first name is 1.3 and last is 1.6
- // I put them together here to test them both at the same time
- $names = rgpost('input_1_3') . rgpost('input_1_6');
- if(!ctype_alpha($names)) {
- $form['fields'][0]['failed_validation'] = true;
- $form['fields'][0]['validation_message'] = 'Sorry, please use only letters in your name.';
- $validation_result['is_valid'] = false;
- }
- // update the form in the validation result with the form object you modified
- $validation_result['form'] = $form;
- return $validation_result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement