Soma string

by Rapha Souza

HTML

<script type="text/javascript">
    function somarValores(){
        var s1 = document.getElementById("txt1").value;
        var s2 = document.getElementById("txt2").value;
         var s3 = parseInt(s1) + parseInt(s2);
        alert(s3);
    }
</script>



<fieldset>
    <legend>Cálculo do salário</legend>
    <label>Valor 1:</label>
    <input id="txt1" type="text"/>
    <label>Valor 2: </label>
    <input id="txt2" type="text"/>
    <button id="somar" onclick="somarValores()">Somar</button>
</fieldset>