Check for alphanumeric
For more details, look at the regex Q on SO.
$name="input string 123";
// Doesn"t allow:
// Pre-/Appending white space
// Not more than one space in between
// Non-alphanumeric characters (lower case)
if( ! preg_match( "/^[a-z0-9]+([\\s]{1}[a-z0-9]|[a-z0-9])+$/i", $name ) )
{
// Output Error Message
}
// Or: Does only allow
// Alphanumeric character (lower & upper case)
// Dash & underline "-", "_" - makes (imho) sense
if( ! preg_match( "/^[A-Za-z0-9-_",'\s]+$/", $name ) )
{
// Output Error Message
}
Error Message
You need to do this via Ajax. Best would be to look over the search results. Another (maybe) good reference would be to inspect the code of some ajax login plugins for a “how-to”.
Related Posts:
- Hebrew username
- How to translate “ERROR: Invalid username. Lost your password?”
- How to change a username?
- Change default ordering of display name
- use of nickname and nicename?
- How to retrieve lost username/ email log- in ?
- How can I allow Arabic usernames in WordPress
- Preg_Match(): compilation failed unknown property name
- Reset admin and password
- How to recover lost username?
- How to add @ symbol to user url
- How to assign a UserName value at creation
- How can hackers access WP usernames? [duplicate]
- Disable author admin just use name.
- I want to use my username to post blog posts, is this advisable?
- What do ++ and *+ mean?
- Regex lookahead, lookbehind and atomic groups
- How can I write a regex which matches non greedy?
- RE error: illegal byte sequence on Mac OS X
- regular expression “.*[^a-zA-Z0-9_].*”
- How to remove parentheses from string [duplicate]
- Regex Match all characters between two strings
- Javascript Regular Expression Remove Spaces
- Regular expression to match a word or its prefix
- python regular expression “\1”
- Regex pattern inside SQL Replace function?
- Regular expression to stop at first match
- My Vim replace with a regex is throwing a `E488: Trailing characters`
- Case insensitive regular expression without re.compile?
- Detecting errors generated by $wpdb->get_results()
- WordPress 5.5 – ReferenceError: commonL10n is not defined error
- Showing WP_Error message with admin_notice action hook
- Adding WordPress API Endpoint With Multiple Parameters
- WordPress URL rewrite regex
- What add_rewrite_tag()’s RegEx matches against?
- Does wordpress have an error log?
- Functions.php reverted to new one
- ‘Invalid post type’ error when importing from one site to another
- PHP notice coming from the WordPress core?
- How to filter out shortcode when displaying the_excerpt() in the loop?
- Unable to Upload Images on Local Windows Install
- Uncaught TypeError: jQuery is not a function
- Call to undefined function get_userdata in user.php
- Only Homepage not loading properly
- PHP Fatal error: Call to a member function get() on null in /wp-includes/cache.php on line 123
- $wpdb doesn’t like to store arrays
- Extending WP_Widget throws error when Monster Widget used
- Custom rewrite_rules – only pass numbers and not alphabetic characters
- Any way to check the integrity of a WordPress site?
- How to fix blocked cookies error that doesn’t let me log into wp-admin?
- Mute Debug Messages from Plugins
- Warning: An unexpected error occurred. Something may be wrong with WordPress.org
- Visual editor not working after update
- Stop saving process when metabox is invalid [duplicate]
- Front end empty (i.e. nothing displays); Back end looks fine; What are possible causes?
- What do these phpMyAdmin errors mean on my WordPress databaes?
- Website Warning: call_user_func_array() expects parameter 1 to be a valid callback, class ‘Wppr_Public’ does not have a method ‘amp_support’
- Using preg_replace() with the_content filter
- XML Sitemap Generator can’t notify google and bing
- enqueue script with get_shortcode_regex
- php preg_match with multiple patterns
- “Sorry, this file type is not permitted for security reasons.”
- “HTTP Error” or Network Error (tcp_error) when uploading image
- WordPress not logged in locally with correct username and password
- Dummy data error
- How can I globally italicize certain text?
- Username was changed to “admin”
- W3 Total Cache “Preview mode could not be disabled” [closed]
- Looking for Functions File that doesn’t Exist
- Woocommerce checkout required field error
- change wordpress pagination url after doing the request
- Blog post is redirecting to home page
- Get_header raises an 500 internal server error
- “This message was added in version X” showing a later version than current one
- admin-ajax.php 403 errors – no caching, permissions are fine
- My website frequently redirect to a different advertisement URL
- Custom Plugin activation error in Multisite
- Redirect after Permalink change – What regex do I use?
- MCAPI.class.php showing some error
- Ajax Response Error
- How to find which plugin crashes
- A plugin is giving me “You do not have sufficient permissions to access this page.” error
- Username from e-mail
- Logging out gives 404 error
- White background, black text – the simplest on earth : “error”!
- My wordpress site must be being affected by outside sources [duplicate]
- problem with php function error
- WordPress Plugin: Demon Image Annotation
- index page is not loading [closed]
- Regex for pdf’s – Old .asp Site folder structure to new WordPress Media Folder(s)
- WordPress error Fatal error: Uncaught TypeError: Argument 3 passed to Automattic :get_setting_for_feature() [closed]
- Use Regex Redirection via htsaccess for RSS Feeds WordPress
- syntax error, unexpected ‘=>’ (T_DOUBLE_ARROW) [closed]
- Error code 499 on specific cron job
- Please Help Me, How to Fix PHP Error Undefined Array Key “srcset”
- Can’t create new pages in wordpress
- My websit dosent worke http errors 500
- WordPress MU: Cookie error when trying to login on network WP instance
- 403 forbidden in admin console: fix seems to be temporary and then error is back
- Custom Post Type slug has the same Redirection entry