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?
- How is the AND/OR operator represented as in Regular Expressions?
- OR condition in Regex
- Using or ‘|’ in regex [duplicate]
- What is a Context Free Grammar?
- python .replace() regex [duplicate]
- Regex not operator
- What does \’.- mean in a Regular Expression
- Regex not operator
- What do ++ and *+ mean?
- How can I exclude one word with grep?
- Javascript split regex question
- How can I validate an email address using a regular expression?
- Regular expression to match a line that doesn’t contain a word
- Matching a space in regex
- Regex not operator
- How to accept space in regex?
- Difference between \b and \B in regex
- How to match “any character” in regular expression?
- regex match any whitespace
- Regex: ignore case sensitivity
- What does the regex \S mean in JavaScript?
- whitespace in regular expression
- How can I validate an email address using a regular expression?
- How do I use a regex in a shell script?
- Regex: ignore case sensitivity
- Python regex AttributeError: ‘NoneType’ object has no attribute ‘group’
- Regular Expression for alphanumeric and underscores
- What is the difference between the regular expressions [^\d\s] and [\D\S]
- Regex: AttributeError: ‘NoneType’ object has no attribute ‘groups’
- Regular Expression for alphanumeric and underscores
- re.sub erroring with “Expected string or bytes-like object”
- grep –ignore-case –only
- Regex AND operator
- python re.split() to split by spaces, commas, and periods, but not in cases like 1,000 or 1.50
- python re.split() to split by spaces, commas, and periods, but not in cases like 1,000 or 1.50
- Regex to test if string begins with http:// or https://
- Regular expression negative lookahead
- Regex how to match an optional character
- Regex lookahead, lookbehind and atomic groups
- Regular Expression to match string starting with a specific word
- Regular Expressions: Is there an AND operator?
- Writing a very simple lexical analyser in C++
- Regular expression to match standard 10 digit phone number
- Regular Expression.how to add optional character at end of regex
- Regular Expression with wildcards to match any character
- What is a non-capturing group in regular expressions?
- How to find all occurrences of a substring?
- What is a good regular expression to match a URL? [duplicate]
- What is a good regular expression to match a URL? [duplicate]
- Does “\d” in regex mean a digit?
- Understanding regex in Java: split(“\t”) vs split(“\\t”) – when do they both work, and when should they be used
- Is there a difference between /\s/g and /\s+/g?
- Split string on whitespace in Python
- How to validate an email address in PHP
- What is a non-capturing group in regular expressions?
- RegEx Ignore Case
- JavaScript replace/regex
- Regular expression to match standard 10 digit phone number
- How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops
- Python string.replace regular expression
- Regex for numbers only
- How to match “any character” in regular expression?
- how to replace quotation marks with \”
- Remove all special characters, punctuation and spaces from string
- This can be done without regex:
- How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops
- Python string.replace regular expression
- Symbol for any number of any characters in regex?
- Grep and Python
- Regex – Does not contain certain Characters
- How to replace ” \ ” with ” \\ ” in java
- A regular expression to exclude a word/string
- Regex how to match an optional character
- How to validate an email address in JavaScript
- Remove properties from objects (JavaScript)
- Using Bash regex match (=~) where regex includes quotes (” characters)
- Searching for UUIDs in text with regex
- Regular expression to match a word or its prefix
- What does regular expression \\s*,\\s* do?
- How can I remove punctuation from input text in Java?
- Regular expression for exact match of a string
- Regex that accepts only numbers (0-9) and NO characters
- Using the star sign in grep
- Regex optional group
- Regex for string contains?