I have refined the code you've provided a bit. It seems that you are using the "ID" property on every element, which I thought unnecessary and can be avoided.
1. Also I have noticed that in your code you've used the "size" property associated with the "password" textbox and button element incorrectly. The "size" is a property that usually used with text box elements to denote how many character can be entered into them. It doesn't represent the "width" of the element. If you want to adjust the "width" of the input elements you can use CSS like the following manner.
Code:
<input name="new_pass1" type="password" style="width: 150px;">
2. I have avoided the usage of inline event handling in my code in which I've associated the event handler through JS code
3. I have avoided the usage of deprecated "align" property from input elements. If you want to align the elements try to use CSS.
Here is the modified JS and HTML markup
Code:
<script type="text/javascript">
function password_check(){
var form = document.forms['log']; //Form element
if(form && form.elements['new_pass1'].value === form.elements['new_pass2'].value) {
form.submit();
} else{
alert('Either the form object is null or the value checking is false);
}
}
window.onload = function(){
var form = document.forms['log'];
form.elements['Submit'].onclick = password_check;
}
</script>
Code:
<body>
<form name="log" method="POST" action="<%=user_ver%>">
<input name="new_pass1" type="password" size="50"><br>
<input name="new_pass2" type="password" size="50"><br>
<input name="Submit" type="button" value="SubmiT">
</form>
</body>
Hope this helps.
Bookmarks