How to remove double quote use onkeyup attr inline? [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I tried
<input type="text" name="first_name"
onkeyup="value=value.replace(/[\-\'\.\,\/\`\:\~\!\#\#\$\%\^\&\*\(\)\_\+\=\;\|\{\}\[\]\<\>\?]/g,'')">
it works for almost all special chars, but when I add a double-quote filter like
<input type="text" name="first_name" in first
onkeyup="value=value.replace(/[\"\-\'\.\,\/\`\:\~\!\#\#\$\%\^\&\*\(\)\_\+\=\;\|\{\}\[\]\<\>\?]/g,'')">
it seems to not allow to do like that. I want to custom remove the mark I want.

You can put your code in an external function instead of placing it inline. It's just that the " interferes with the html attributes' " and break the code.
document.querySelector(".no-special-chars").addEventListener("keyup", function(){
this.value = this.value.replace(/[\"\-\'\.\,\/\`\:\~\!\#\#\$\%\^\&\*\(\)\_\+\=\;\|\{\}\[\]\<\>\?]/g,'');
});//keyup()
<input class="no-special-chars" type="text" name="first_name" />

Related

How can I make first number of phone number cannot be zero? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
My html like this :
<input type="number" />
I had validation number, so user only input number. I want the first digit to be non-zero
How can I do it?
You can use text input with a pattern attribute:
<form action="/action_page.php">
Phone Number: <input type="text" name="phone_number" pattern="[1-9][0-9]+" title="Phone number without a leading zero" required="required">
<input type="submit">
</form>
and to use with number you can use this:
<input type="number" oninput="this.value = this.value.replace(/^0/g, '');" >

Adding more balance via a html input to a javascript variable? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Photo of the website
I have a school project and I need to make a website where I can add more balance to my account. But I can't figure it out.
I would like to make an HTML number input and then that input needs to add up with my existing balance. But I can't make it work
This is the code I have:
<fieldset>
<legend>Opwaarderen</legend>
<input type="number" id="opwaarderen">
<input type="submit" onclick="opwaarderen()">
</fieldset
But how can I make the Javascript function? So that the input will add up to my already existing balance.
This will help
var currentCredit=0;
$("#a").click(()=>
{
alert(currentCredit+=Number($("#opwaarderen").val()));
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<fieldset>
<legend>Opwaarderen</legend>
<input type="number" id="opwaarderen">
<input type="submit" id="a">
</fieldset>

auto update form with javascript [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want the text i type in
<input type="text" name="text1">
will automatically be updated in
<input type="text" name="text2">
by using JavaScript.
Anyone know how to solve it?
Thanks in advance
You can use the onkeyup event and populate the second <input> with the text of the first one, like this:
var inp1 = document.getElementsByName('text1')[0],
inp2 = document.getElementsByName('text2')[0];
inp1.addEventListener('keyup', function(e) {
inp2.value = this.value;
});
<p>Input 1: <input type="text" name="text1" placeholder="write something here..."></p>
<p>Input 2: <input type="text" name="text2" placeholder="ant it will show up here..."></p>
Test it using the "Run code snippet" button.

Turn background transparent when text field is empty and no cursor (onUnfocus) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
When text field is empty and no cursor int the text field want to transparent and spell checker is not working. the showing the result <div> want to little left.
That code CSS or JavaScript or in PHP.
<form method="post" name="tasktitleform">
<input id="Search" class="search" type="text" name="Search" contenteditable="true" spellcheck="true" />
<input class="save" value="submit" type="submit" />
</form>
The footer code is not sticking under the window. That's way I copied from google and simply change the color to light yellow.
In this spellcheck not working CSS not working in the IE.
your question is not clear. Based on your question title, here is jquery snippet for changing opacity on focus and focusout events
$("#tbx").focus(function(){
$(this).css("opacity","1");
});
$("#tbx").focusout(function(){
if($(this).val()=="")
$(this).css("opacity","0.6");
});
jsfiddle sample http://jsfiddle.net/zxdwa0e8/3/

How to replace search box? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
So here is my site: http://dll-download.us/
I want it where if someone clicks on "Can't Find a File?", I want it to instead select the search box so they can search for it instead.
Code of search box on my site:
<form method="get" action="/search" id="search">
<input name="q" type="text" size="40" placeholder="Search for a DLL" />
</form>
The easiest way to do this would be to add a click event to the can't find a file link, then use JavaScript to focus the text box.
function setFocus() {
document.getElementById("myTextbox").focus();
}

Categories

Resources