I have two input field. one with name and other is verify name. I want to add some validation into it. If my first input contains 'robert' then user only can type "robert" in next field. But it is not giving me the desire result
<head>
<script type="text/javascript">
$(function(){
var jn= [];
$('#first').keypress(function(e){
var d= e.charCode || e.keyCode;
jn.push(d)})
var jm=[];
$('#second').keypress(function(e){
var f= e.charCode || e.keyCode;
jm.push(f)
for(i=0;i<jn.length;i++){
for(z=0;z<jm.length;z++)
{
if(jn[i]==jm[z]){
alert('hiii')}}}})
})
</script>
</head>
<body>
name
<input type="text" id="first" />
verify name
<input type="text" id="second" />
</body>