How to validate a Text field?
-
Hello,
I have added an “Email” and a “Confirm Email” field as both of type ‘Text’.
Under the “Billing” tab, I can the Abbreviation of these two fields, as: “email” and “myfield2”.
I have written the following php code with my themes’s functions.php file, to check whether the entered email and confirm email do match, but it is Not at all working:-
————————————————————————————add_action('woocommerce_checkout_process', 'is_email_match'); function is_email_match() { $email1 = $_POST['email']; $email2 = $_POST['myfield2']; // your function's body above, and if error, call this wc_add_notice if ($email1<>$email2) { wc_add_notice('Hey... Email and Confirm Email should match','error'); } }
Please let me know where the custom field names can be found.
Thanks.
- The topic ‘How to validate a Text field?’ is closed to new replies.