NameSilo

Php Q

SpaceshipSpaceship
Watch

noswad

Established Member
Impact
1
Hi,

Im looking for some code to use on my registration form so that if a user enters an invalid character for their username such as * # _ - an error pop up box will appear.

Thanks for reading.
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
That would be javascript if it pops-up. You could use some pretty easy PHP that will just redirect to he reg. page if it encounters an invalid character.
 
0
•••
0
•••
something like this
you'll have to tweak it though
PHP:
<?php
$username = $_POST['username'];

if ($username == ' ') {
$error = 'Invalid username';
}
else {
$error = '';
}

echo $error;
?>
i am not sure how to check if there is a certain character in it. but your best bet is probably ajax
 
0
•••
you could always check once theyve pressed submit, if it has invalid characters in it. that would be a lot easier.
 
0
•••
Albino said:
you could always check once theyve pressed submit, if it has invalid characters in it. that would be a lot easier.

If worried about efficiency/bandwidth
Best to check via JScript or other local handling. Then when you know the data is valid in form, after that POST IT and do database lookup for valid username/password.

You save a whole back and forth trip to server that way. I'm not a strict AJAX purist, but I believe that is one of the things it stresses (I've stopped trying to keep up with all the new acronyms, just read the white paper and try to borrow the best of 'em all... Though sometimes they conflict)
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back