Fork me on GitHub

Nibble Development

Nibble Development

PHP classes and libraries for developers

Text Field

The most basic form input is the text field. The most simple instantiation of the text field class requires just a label:

The second argument can be either True or False, True means that on validation there must be content in the field or it will not be valid, False means that the field does not need any content to be valid.

The third argument is the maximum length of string allowed in the field. As 255 is the maximum Varchar value in a MySQL database, it is recommended to leave this value at 255 if you have no need to change it.

The final argument is a regular expression string. This means that you can match the users input to any pattern desired and the validation will only pass if the string is a match, the default value is a regex that allows any string so if you don’t know regex, or don’t want to know regex, just leave it as it is and it will have no effect.

So a final fully customised text input would look something like:

Luke Rotherfield

Freelance PHP Developer
is a PHP developer dedicated to writing the most awesome liraries for his fellow devs :) enjoy

Latest posts by Luke Rotherfield (see all)


Leave a Reply to MrQ Cancel reply