form表单内的button标签有关问题

form表单内的button标签问题

<form>
        <input type="text" id='username'>
        <button type="button" id='save' onclick="save()">保存</button>
    </form>

 <script>
        function save(){
            var name = document.getElementById('username').value;
            alert(name);

            if(name=='hello'){
                history.go(-1);
            } else{
                alert('输入错误 hello');
            }
        }
    </script>


当button放在form表单里的时候,onclick事件就没有响应,不放在form表单里时,save()方法就得到调用了。
请问,这是什么情况呢?是自动提交了表单,而没有响应吗?



------解决思路----------------------
函数名称换个
<form>
        <input type="text" id='username'>
        <button type="button" id='save' onclick="save1()">保存</button>
    </form>
 
 <script>
        function save1(){
            var name = document.getElementById('username').value;
            alert(name);
 
            if(name=='hello'){
                history.go(-1);
            } else{
                alert('输入错误 hello');
            }
        }
    </script>

------解决思路----------------------
<button type="button" id='save' onclick="save()">保存</button>
不能同名!