|
|
|
|
|
|
Arguments:
Name |
Description |
$field |
The field which should get the focus when the form is displayed |
Description:
Set the focus to a specific field (So that the cursor is placed in a field).
Default, the focus will be set to the first field to the form. When the form is submitted but shown again (because some fields are not valid), the first of the invalid fields will get the focus.
This method has one argument: the name of the field which should get the focus.
Example
<?php
// include the class
include("FH3/class.FormHandler.php");
// create new formhandler object
$form = new FormHandler();
// a textfield & passfield
$form -> textField("Username", "username", FH_STRING);
$form -> passField("Password", "password", FH_PASSWORD);
// set the focus to the password
$form -> setFocus("password");
// submit button below it..
$form -> submitbutton("Login");
// set the onCorrect function
$form -> oncorrect("doLogin");
// flush the form
$form -> flush();
// the commit after form function
function doLogin($data)
{
if($data['username'] == 'admin' &&
$data['password'] == 'passw')
{
// login here...
}
else
{
echo "Error, invalid username or password!";
return false;
}
}
?>
|
Preview image
Latest change: 05 March 10 / 08:49
Comments
Teye Heimans |
22 November 07 / 10:30 |
|
If you do not want to have any field to have a focus, you can use this:
<?php
$form -> setFocus( false );
?>
|
|
|
|
|
|