0
votes

So I'm coding a registration form, and I would like to have "virtual placeholders", that I will control with jQuery, since that HTML5 markup isn't still recognized by some browsers.

The problem is, using form helper and I can't set an initial value for:

<?php echo form_input($username);?>

and

$this->data['username'] = array('name' => 'username',
            'id' => 'username',
            'type' => 'text',
            'max-length' => '20',
            'value' => $this->form_validation->set_value('username'),
        );
3

3 Answers

2
votes

set_value() is only used to re-populate the field to my knowledge. Why not use the native HTML5 placeholder attribute and read that with jQuery for browsers which don't support it yet? First solution via Google: http://www.kamikazemusic.com/quick-tips/jquery-html5-placeholder-fix/

1
votes

set_value() accepts a second "default" value. I do not believe you need to call it with $this->form_validation

it would just be

set_value('username', 'Default Value');

See Docs here, near bottom of page.

1
votes
You can use this. its working

$dataYear = array(  'name'        => $module.'-year',
                      'value'       => set_value($module.'-year'),
                      'size'   => '5',
                      '**Maxlength' => '4',**
                      'id'  => 'year'
                     );