<script type="text/javascript">
$.validator.setDefaults({
    submitHandler: function() {
        document.getElementById("frm_newUser").submit();
    }
});
$().ready(function() {
    $(".btn_save_form").click(function(){
        $("#frm_newUser").submit();
    });
    $("#newusername").blur(function(){
        var newpasswd = "<?php echo substr(md5(time('YmdHis')),0,5); ?>";
        $("#newpasswd").attr("value", newpasswd);
        $("#firstname").focus();
    });
    $("#frm_newUser").validate({
        rules: {
            newusername: "required",
            newpasswd: "required",
            txt_email:{
                required: true,
                email: true
            }
        },
        messages: {
            newusername: "Required Field.",
            newpasswd: "Required Field.",
            txt_email: "Required Field."
        }
    });
});
</script>
<form name="frm_newUser" id="frm_newUser" method="post" enctype="multipart/form-data" action="index.php?option=com_users">
<?php if(!empty($message)){ ?><div id="capa_mensaje"><?php echo @$message; ?></div><?php } ?>
<div class="toolbar_right">
<ul>
    <li>
    <a href="index.php?option=com_users&controller=Users&action=getUsers">
    <img src="../imagenes/icon-cancel.png" alt="Cancel" border="0" />
    </a>
    </li>
    <li><a href="#" class="btn_save_form"><img src="../imagenes/icon-save.png" alt="Save" border="0" /></a></li>
</ul>
</div>
<div style="clear:both; overflow: hidden"></div>
<span class="title_form"><label class="txt_title_form">New User</label></span>
<div id="div_frmuser">
    <div class="row_reg">
        <label>Username:</label>
        <input type="text" class="form_input" name="newusername" id="newusername" />
        <div style="clear: both; overflow: hidden"></div>
    </div>
    <div class="row_reg">
        <label>Password:</label>
        <input type="text" class="form_input" name="newpasswd" id="newpasswd" readonly />
        <div style="clear: both; overflow: hidden"></div>
    </div>
    <div class="row_reg">
        <label>Fisrtname:</label>
        <input type="text" class="form_input" name="data_user[firstname]" id="firstname" />
        <div style="clear: both; overflow: hidden"></div>
    </div>
    <div class="row_reg">
        <label>Lastname:</label>
        <input type="text" class="form_input" name="data_user[lastname]" id="lastname" />
        <div style="clear: both; overflow: hidden"></div>
    </div>
    <div class="row_reg">
        <label>Email:</label>
        <input type="text" class="form_input" name="txt_email" id="txt_email" />
        <div style="clear: both; overflow: hidden"></div>
    </div>
    <div class="row_reg">
        <label>Photo:</label>
        <input type="file" name="fphoto" alt="fileimage" />
        <div style="clear: both; overflow: hidden"></div>
    </div>
</div>
    <input type="hidden" name="controller" value="Users" />
    <input type="hidden" name="action" value="addUser" />
    <input type="hidden" name="data_user[date_create]" value="<?php echo date("Y-m-d H:i:s"); ?>" />
</form>