CB Query Field has received its second major upgrade. It now includes "Query Validation" for several fieldtypes such as text, textarea, name, username, integer, etc.. (basically all internal fieldtypes that require user supplied values). Note due to the way editor fieldtypes work it is not supported. Password fields are also not supported for security purposes.
Query validation will take the value the user has supplied to your field and allow it to be substituted into a database query. This database query will determine if the value should be validated or not. You could for example query the database and ensure they're not supplying a value that has already been supplied.
Validation is PHP side and optionally Ajax enabled. So you can validate a field using a database query without a single page load! Custom translation supported error message for invalid values also available.
Query can be on an internal or external database. Example usage as follows.
Query:
Code:
SELECT * FROM `#__users` WHERE `username` = '[value]'
Mode: Internal
Validate On: Empty Results
Validate Error: Not a valid input.
Ajax Validation: Enabled
With the above example the value supplied to the field must be an existing username within your users database table. If it is not then the field will fail validation.