Javascript, I am not being able to cursor to input box - javascript

I can't set focus on html input, I tried this code, And it doesn't work.
document.getElementById('ember19').focus();
document.getElementById('ember19').click();
document.getElementById('ember19').select();
document.getElementById('ember19').value='Badman55555#hotmail.com';
document.getElementById('ember19').setAttribute('value','Badman55555#hotmail.com');
document.getElementById('ember22').focus();
document.getElementById('ember22').click();
document.getElementById('ember22').select();
document.getElementById('ember22').value='Bad123456';
document.getElementById('ember22').setAttribute('value','Bad123456');
Please before answer try your code on this page
https://id.sonyentertainmentnetwork.com/signin/

Try using autofocus
<input type="text" name="myInput" autofocus />
https://www.w3schools.com/tags/att_autofocus.asp

Related

Removing input autocomplete, in javascript and html doesn't work

I have a form and add text style in the input, if user click the input, the text shrink and goes up. It's working good till google autocomplete remember username and password, the autocomplete is messing the style.
So far I tried using autocomplete="off", but doesn't work:
<input type="text" autocomplete="off" class="form-control" size="15" name="login" id="login" required/>
<input type="password" autocomplete="off" size="15" class="form-control" name="password" id="password" required/>
Also I tried using js, but doesn't work as well:
function connectForm() {
document.querySelector(".totalconnect_form").autocomplete = "off";
}
connectForm();
Is there a way to solve this? to remove the autocomplete?
Or if not possible, I can use js using condition, but I'm not sure how to target the autocomplete in js, any advice will be helpful, thanks.

Auto-Complete Off is not working in Chrome

I am trying to disable google password autocomplete field in password text-box in chrome browser. I tried autocomplete off but that doesn't work then I tried auto complete : "new password" that also doesn't work. Suggest me any solution for this problem.
Thanks in advance.
here is my code
i tried
autocomplete="new-password"
I've tried to disable it -- at this point only thing i the autocomplete='off' doesn't work
i would try this --
set the password box with a value on the pageload
$("input[type='password']").val(" ");
on focus set the value to empty
$(document).on("focus","input[type='password']",function(){
$(this).val('');
});
For this you can use a trick. Chrome always track first <input type="password"> and the previous <input>. So add this:
<input style="display:none">
<input type="password" style="display:none">
To just after <form> tag started and the case will be resolved.

How to place cursor at the beginning of input box using with jquery inputmask?

I have an input that I used with jquery inputmask. It works well, but what I want to do is to place the cursor to the beginning of the input box as the user click on the input box.
Here is my input tag:
<input type="text" class="form-control" name="phone" id="phone" data-mask="999999999?9" />
Please help me out from this problem.
Thank you in advance.

Textbox like gmail login page

I want a textbox functionality like a gmail login page textbox. Right now I have code like this:
<script>
function inputFocus(i){
if(i.value===i.defaultValue){ i.value=""; i.style.color="#000"; }
}
function inputBlur(i){
if(i.value===""){ i.value=i.defaultValue; i.style.color="#888"; }
}
</script>
<body>
<input type="text" name="firstname" title="First Name" style="color:#888;"
value="First Name" onfocus="inputFocus(this)" onblur="inputBlur(this)" />
...
</body>
The problem with this code is when I select the tetbox, type "First Name" and if I reselect the textbox the text is clearing. And also gmail login page textbox functionality looks great, until I type a letter it shows the transperent text. But I don't know how to implement it.
For the "transparent text" you need to use the placeholder attribute:
<input type="text" name="firstname" ... placeholder="Email">
are you looking for a placeholder ??
If so... you can do like this..
<input type="text" name="somename" id="someid" value="" placeholder="Email">
Placeholder is used to display the text in the text box and will disappear as soon as you start typing..
If you want to delete the "transparent text" once start typing, you can use placeholder attribute of input element
This attribute is introduced in HTML5 to handle this scenario without writing any peice of javascript code
Your html code should look like this
<input type="text" name="firstname" placeholder="First Name"/>
This will also work as desired when you delete your text, as it will reset the transparent text back again.
Also, here is a working example on jsfiddle
I also, encourage you to review new elements and attributes introduced in HTML5, it will save a your time writing a lot of javascript to handle already built in functionalities

HTML/JS Show a text next to a input box

I want to put a text next to an input box, after an successful if clause.
Just need to know how to show up such text.
Thanks
<input type="text" class="form-control" id="username" placeholder="Username" name="username" required autofocus/>
And my code snippet:
$("#username").append("<p>This username is not available</p>");
If your using jQuery, you can simply use:
$("#your-element-id").append("<strong>whatever text you need to add</strong>");
You will need to make sure that #your-element-id contains the input box. You may need to add the relavant CSS as well.

Categories