The best way to do form validation is with a combination of JavaScript and PHP.
The reason why you want to perform JavaScript validation is to give the users a chance to correct their errors without submitting the form. Plus, it will stop any casual mistakes. You will also want to ensure validation on the back-end in case JavaScript is turned off.
Either way, sanitizing your data should be part of this process. Use any of these WordPress functions to help you there: Data Validation.
For JavaScript validation, I recommend the jQuery Validation plugin. It’s super easy to implement and customize.
As for your PHP validation, you can try adding this to check for empty values: $_POST['title'] != ''
Related Posts:
- Front-End Post Submission
- How to upload post thumbnail while wp_insert_post?
- Publish pending article from front end with a button?
- Get names of authors who have edited a post
- Edit a post from frontend. post_tags get saved, but not separated
- Get the user type of an author
- Developing a secure front end posting form
- How can I edit a post from the frontend?
- Developing a secure front end post editing form
- Post from front-end only by logged in users, form posts as “posted by:
- upload featured image from front end using wordpress add media button
- Post & edit a post from front end along with upload, dropdown, and other inputs
- Frontend Post Excerpt field mapping
- Redirection not working in this front end post submission form?
- How to change the color theme per post?
- Adding an image to a non existing post
- How to make a bilingual front-end post using the plugin WP User Frontend and Polylang or qTranslate?
- Change Post Status From Front End
- 404 error on default post type and default taxonomy fronted page
- Make post_content and other custom fields required
- Lock post editing to one user at a time – wp_check_post_lock
- Front end post submission form with duplicate type fields
- Replace image name on upload to the new post name on front-end form
- Edit the post title from the frontend
- Can i have more than one form for front end posting in one template [closed]
- Get Users Post ID
- WordPress wp_editor to post and edit
- How to limit post (Exception pages) for current user in each role in front end?
- Create posts by any logged in users
- How to generate an HTML link automatically from URL in a users’ post
- how let users select categories for posts in frontend?
- Allow reader to reorder posts for themselves (oldest first)
- Send the post id to a front end edit post form
- Post/Edit/Delete Post From Frontend… How?
- Send/Publish a Post front end
- How Can I Limit Users to Post Creation For My Frontend Theme?
- User driven content problems
- Create post from form with image
- Stop Authors from submitting spam post
- Get WordPress post content by post id
- Get page ID of page that is set as the posts page
- Get Posts Under Custom Taxonomy
- How to limit the number of posts that WP_Query gets?
- Stop WordPress Wrapping Images In A “P” Tag
- When is the ‘post_content_filtered’ column in database cleared by WordPress?
- Turn a URL into an Attachment / Post ID
- GET the excerpt by ID
- Stop WordPress automatically adding tags to post content
- Determine if page is the Posts Page
- How to get ‘post_content’ without stripping tags?
- How to add an admin notice upon post save/update
- Print Current Post Index number within Loop
- Should we trust the post globals?
- Optimize post insert and delete for bulk operations?
- Get the Current Page Number
- How do you add thumbnail support for custom post types?
- How to mark every 3rd post
- Change Posts per page count
- Keep featured content post in homepage with original order
- How to display related posts from same category?
- Can posts have parents?
- Is there a action hook for the “Empty Trash” button?
- How to end the excerpt with a sentence rather than a word?
- How do I check if I linked to a post before I delete it?
- How to change the case of all post titles to “Title Case”
- Appending content with broken in 4.4
- How to get posts published between a date and today?
- ZIP up all images displayed in a [gallery] and offer as download link
- How to detect single.php (but not single-portfolio.php)?
- How to check if post meta key exists or not in wordpress database
- How to remove a column from the Posts page
- Submit post and upload image from front-end
- removing inline styles from wp-caption div
- What is the use of to_ping and pinged column?
- How to use “Add link” pop up for a WordPress widget
- Remove Categories / Tags From Admin Menu
- How to retrieve text only from wp_content() not from wp_excerpt()?
- Stop WP from creating “Sample Page” and “Hello World!” post
- Where is the old post permalink slug stored?
- How to Create Editable Blocks of Text for the Homepage?
- Keyboard shortcut for updating a page or post?
- Add custom Attachment Display Setting for images
- Rewriting post slug before post save
- Apply the_title() filter in post & page title, but not in menu title
- How to Change Order of Posts in Admin?
- is it possible to get next_post_link
- Get post content by ID
- How to get post creation date?
- Update post counts (published, draft, unattached) in admin interface
- Function to execute when a post is moved to trash .
- How to get post ID of the current page/post inside a widget?
- add action only on post publish – not update
- How to display by default only published posts/pages in the admin area?
- How do you add Read more … link to posts?
- How to make comments work for a post loaded per Ajax?
- Is there an if statement that can determine if a post in the loop is the last post?
- Get current menu_order
- How to show related posts by category
- Front end post editing using a form
- Changing the post date and time with function