Title: Implementing conditional logic in form without using plugin
Last modified: January 11, 2019

---

# Implementing conditional logic in form without using plugin

 *  [tony2ttec](https://wordpress.org/support/users/tony2ttec/)
 * (@tony2ttec)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/implementing-conditional-logic-in-form-without-using-plugin/)
 * Hi,
 * I’m trying to figure out how to implement conditional logic in a form without
   using a plugin. Specifically, I’m trying to add functionality that will check
   the fidelity of a phone number entered into a textfield by the user (e.g. to 
   check starting digits, number of characters etc).
 * I’ve been going through the PHP 5 Form Validation examples on w3schools.com but
   the functionality in these examples is not developed for WordPress.
 * I’m new to WordPress development and am looking for advice on where to start.
 * Any help would be much appreciated.
 * Cheers,
    Tony

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/implementing-conditional-logic-in-form-without-using-plugin/#post-11078814)
 * It’s HTML5, not PHP 5.
 * If the browser supports HTML5, all you need to do is use the correct type and
   pattern on the input. If it doesn’t, then it’s not checked. But you should always
   check on the server. Client-side checking can be interfered with.
 *  [tugbucket](https://wordpress.org/support/users/tugbucket/)
 * (@tugbucket)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/implementing-conditional-logic-in-form-without-using-plugin/#post-11079631)
 * [https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel)
 * but yeah, if the browser doesn’t support this, it will fall back to a regular
   text input.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/implementing-conditional-logic-in-form-without-using-plugin/#post-11082397)
 * You would use JavaScript to validate client side. Strip out non-numeric chars
   and count the remaining digits. The chars we use to separate number segments 
   are locale specific and meaningless to phone systems. But the digit count is 
   also locale specific, plus certain digits could be optional. For example, country
   codes are optional within the country, as sometimes are area or region codes.
   So your digit count should accept a range of results, or be able to recognize
   optional portions.
 * How you get JS onto a page in WP is unique to WP, but the actual JS is not any
   different than any other web page. Like Joy said, you must do the same check 
   server side regardless of whether it’s checked client side or not. The client
   side check is optional and mainly serves to make a better UX.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Implementing conditional logic in form without using plugin’ is closed
to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [conditional logic](https://wordpress.org/support/topic-tag/conditional-logic/)
 * [form validation](https://wordpress.org/support/topic-tag/form-validation/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 4 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [7 years, 4 months ago](https://wordpress.org/support/topic/implementing-conditional-logic-in-form-without-using-plugin/#post-11082397)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
