It has how to set focus to the element?

461 views
Skip to first unread message

jose Aparecido

unread,
Jun 17, 2014, 9:32:09 AM6/17/14
to knock...@googlegroups.com

It has how to set focus to the element?

HasFocus know there's more I would have to declare another variable just that this screen will still be more un 15 objects and not like to declare many variables

There is a possibility I set this?

A snippet of code

HTML

<div>  <input type="text" id="email_log" maxlength="50"  data-bind="value: email_log" name="email_log">                                  <input type="password" id="password_log" maxlength="10" data-bind="value: senha_log" name="password_log">                                  <button id="btn_login" data-bind="click: login" >     <span class="label">OK</span> </button>     
</div>                        

JAVASCRIPT
function LoginViewModel() {          this.email_log = ko.observable();     this.password_log = ko.observable();     this.login= function () {         if (isNullOrWhiteSpace(this.email_log()))         {
//to set focus on element here
            alert("Enter the e-mail");                         return false;         }                      jQuery.ajax({                 url: '/Home/',                 cache: false,                 type: 'POST',                 contentType: 'application/json;charset=utf-8',                 data: '{"email": "' + this.email_log() + '","password": "' + this.password_log() + '"}',                 success: function (data) {                                                         }             }).fail(function (h, t, e) {                 alert(e);             });              }; }

Patrick Steele

unread,
Jun 17, 2014, 9:58:29 AM6/17/14
to knock...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages