before you can use any type of table validation you will need to give that element a db link.

sample:  

$this->siteForms->boundElements['username']->db = $this->db;

$this->siteForms->boundElements['username']->addValidation('valueNotInDBTable',array('table'=>'users','col'=>'username'));

If you wanted to allow the user to change their username in a form you would want to specify the original value to be allowed in case they don't change their username.

$this->siteForms->boundElements['username']->addValidation('valueNotInDBTable',array('table'=>'users','col'=>'username','ignoreorignalvalue'=> $this->web_helper->getFormValue("oldusername","","Username")) );

 

The olderuser element would look like this:

 

$this->siteForms->createElement('oldusername',false,'oldusername',"", "UserName");

$this->siteForms->boundElements['oldusername']->form_web_type = "hidden";

$this->siteForms->boundElements['oldusername']->col_name='username';

$this->siteForms->boundElements['oldusername']->auto_populate_db = true;