Questions tagged as 'javascript'

1
answer

Allow only numbers in an input

I have two input fields, latitude and longitude. In it I should only allow the entry of numbers, sign - and. how can I make a function for it?     
asked by 07.10.2016 / 14:03
4
answers

Javascript customize confirm, replace button text "ok" and "cancel", execute function only if clicked ok

How can I customize confirm , overwriting the Ok and Cancel button text? I also wanted to execute the function only if I clicked Ok. Follow the code without success yet <script> function funcao_a() { confirm('funcao A');...
asked by 14.08.2016 / 17:48
1
answer

Problem when verifying if a number is a module of 2 in pure js

I'm trying to do this: if(i % 2){ console.log(i); } i is the variable of is coming from a for loop. Why is not it working?     
asked by 05.10.2016 / 16:37
3
answers

Disable submit button to not make multiple calls to server [duplicate]

I'm trying to disable the button after clicking, so I will not be sending the form data multiple times if the user clicks. My button <input type="submit" class="formButton" name="send" id="send" value="Enviar"> my js...
asked by 24.12.2015 / 11:54
1
answer

In what situations use each type of prototype in HTML elements?

In "prototypes" I have used the Element.prototype and HTMLElement.prototype several times. I wanted to know what each one is and what the difference between them is, if possible. Because in some tests, like these, I had the same re...
asked by 15.01.2016 / 15:54
1
answer

Problems with events in dynamically created elements

My intention is: A listing where you can add <div> and delete the divs added with a "button" inserted in each div . The page already comes with a fixed% inserted divs that are the same as those that will be added....
asked by 16.07.2014 / 03:58
2
answers

Regex in Javascript: grouping

As input from the user I am expecting pairs of numbers separated by commas: // se for um par só 1-2 // se for mais de um par 1-2,3-4,5-6 I expect something like this: [ [1, 2], [3, 4], [5, 6] ] I'm in doubt about getting this ou...
asked by 18.06.2014 / 18:40
2
answers

Linebreak encoding (\ n) in Javascript alert ()

Hello, I need to make a replace in the string </script> by transforming it to the string \n . The problem is that unfortunately my PHP project is with charset=ISO-8859-1 , while javascript runs with UTF8 . Wh...
asked by 17.09.2014 / 19:42
2
answers

How to remove a link from a string in javascript?

I would like to know how I can do to remove the link from a string in javascript. str = "hey olha isso http://google.com.br, legal né?" var test = str.description.replace(/.*?:///g, ""); Expected result:    Hey look at this, cool huh?...
asked by 28.08.2015 / 20:21
3
answers

Why do not I need to pass parameters to this function?

I would like to know how function passing as a parameter in JS works, I'm starting the language now and I needed to make a call of EventListenner document.getElementsByClassName("informacao")[0].addEventListener("mouseover", troca(b...
asked by 26.02.2016 / 21:51