Yii Framework Forum: Textbox Focus - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Textbox Focus Getting focus omn first textbox Rate Topic: -----

#1 User is offline   khush@l 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 134
  • Joined: 26-March 13

Posted 24 July 2013 - 09:09 AM

Hello everyone,

I want to make focus on first textbox when my create user form is loaded in application.
I mean that cursor is directly pointing to the textbox and user can directly start typing without pressing "tab" key or "mouse". When form loads at that time focus should be on first textbox that is username.
Waiting for your suggestions.

Thanks in advance!!!
0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,707
  • Joined: 04-March 10
  • Location:UK

Posted 24 July 2013 - 09:17 AM

I use something like this:

	<? $form = $this->beginWidget('CActiveForm', array(
		'id'=>'editUser',
		'focus'=>'#editUser input:text:empty:first,'
		       . '#editUser input[class=error]:first',
	)); ?>

0

#3 User is offline   khush@l 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 134
  • Joined: 26-March 13

Posted 24 July 2013 - 09:29 AM

Thanks!!!!

Also we can write directly inside textbox like :

echo CHTML::textField('usr_name','',array('size'=>25,'autofocus'=>"autofocus"));

So when form loads at that time it will directly focusing this textbox.

BTW thanks for your support.
0

#4 User is offline   peebowl 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 05-April 13

Posted 01 December 2017 - 04:48 AM

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'annual-budget-form',
	'enableAjaxValidation'=>false,
	// 'focus'=>array($model,'Budget_Amount') for $form->textField
	'focus'=>'#Budget_Amount' // for CHtml::textField
)); ?>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users