Forums

Minimum Characters in a Form Field

daemonhunt 27 Oct, 2009
Hello

Joomla with Community Builder has a minimum character count of 3 for the username.

I am using a multi-page Chronoform and the CF_CB Plugin to register with Community Builder, but I'm not sure what server side validation I can use make sure a user enters 3 characters or more for the username.

I am currently using server side validation to test that the username isn't already in use, and that two passwords are the same (verification).

Could somebody post some "minimum alpha-numeric characters" validation code for me?

With Thanks
daemonhunt 27 Oct, 2009
Thanks Bob

For those that want to know how to do this specifically see below. I actually used mine as I discovered that Community Builder has a minimum username length of 3 characters.

In your server-side validation box (assuming it is on) enter the following:

<?php
//verify myfield length
if (strlen($_POST['myfield']) < X)
return 'Your username must contain X or more characters.';
?>


Assume that myfield should be the actual name of the form field you wish to validate, and that X should be changed to a numeral representing the number of characters you wish to validate against. Pretty simple really. You can change < to > etc. if you like.
This topic is locked and no more replies can be posted.