
Comparar dos numero para saber si son iguales.
Publicado por Arturo R (2 intervenciones) el 23/05/2017 05:35:16
Hola busco realizar un comparador de numeros de serie, que teniendo dos cajas se capture el numero de serie en ambas y sin son iguales me cambie el background a verde y si no lo cambie a rojo. Re quiero de su ayuda si alguien me puede ayudar le agradeceria.
Este es lo que yo estaba haciendo pero no sale :)
Este es lo que yo estaba haciendo pero no sale :)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<script type="text/javascript">
function valida(){
var num1 = document.getElementById('Serie').value;
var num2 = document.getElementById('confirm_serie').value;
if(num1 == num2)
{
cambiar_fondo();
}
else
document.body.style.backgroundColor = "red";
}
function cambiar_fondo() {
obj = document.getElementById('id_del_div');
obj.style.backgroundColor = (obj.style.backgroundColor == 'rgb(36, 122, 46)') ? 'transparent' : '#247a2e';
}
</script>
<body>
<p>FAVOR DE ESCANEAR EL NUMERO DE SERIE 2 VECES</p>
<p>PLEASE SCAN SERIAL NUMBER 2 TIMES </p>
<link rel='stylesheet' media='screen and (min-width: 200px) and (max-width: 400px)'/>
<form onSubmit="return valida()">
Serial Number :<input type="text" id="Serie" name="Serie" /><br/>
Serial Number :<input type="text" id="confirm_Serie" name="confirm_Serie"/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
Valora esta pregunta


0