[eluser]cobolCowboy[/eluser]
Hello,
As things stand right now in this form, I figured out how to set the focus on the email input box when the form loads using the js at the bottom.
Actually the first line of js I've coded.
However, if the user inputs a valid email inthe text box and fails to enter a password, it makes no sense to focus on the email text box.
Now, I realize that Javascript may play a role here, but I have no idea how.
Code:
<?php // Login Form ?>
<h1>Login</h1>
<h4>First time here? <a href="<?php echo base_url();?>user/signup"> Sign Up!</a></h4>
<div id="login">
<fieldset class="yui3-g">
<div class="yui3-u-1-2">
<br />
<?php
$attributes = array('class' => 'email', 'id' => 'myform');
echo form_open('user/login', $attributes);
?>
<label for="email">Email address</label><br />
<input type="text" name="email" id="email" value="<?php echo set_value('email'); ?>" size="80" maxlength="80" /><br />
<?php echo form_error('email', '<span class="err2" id="errEmail">', '</span>'); ?>
<br />
<label for="password">Password</label><br />
<input type="password" name="password" id="password" value="<?php echo set_value('password'); ?>" size="60" maxlength="60" /><br />
<?php echo form_error('password', '<span class="err2" id="errPassword">', '</span><br/>'); ?>
<a href="<?php echo base_url();?>user/forgotPassword"><span style="font-size:small;">Forgot your password?</span></a>
<br />
<input type="image" alt="submit" src="<?php echo base_url();?>app/images/buttons/login.png" value="Login" class="right submitbutton" />
<?php echo form_close()?>
</div>
<div class="yui3-u-1-2">
<img class="right" src="<?php echo base_url();?>app/images/login.jpg" alt="login image">
</div>
</fieldset>
</div>
[removed]
document.forms['myform'].elements['email'].focus();
[removed]
Any one know how to do that?
I've added "id=" to the form_error function thinking I would use the id to somehow determine if the error line was generated and focus on the first one I find.
If I don't find anything, as in the first time through, I would default it to the first text box.
I'm not a programming newbie, but to javascript, well still very green.