Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8843013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:06:37+00:00 2026-06-14T11:06:37+00:00

I have two input field. one with name and other is verify name. I

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:06:38+00:00Added an answer on June 14, 2026 at 11:06 am

    I believe you’re over thinking it. Your solution also doesn’t lend itself to editing (due to having to track the array of keycodes). Try something like this

    http://jsfiddle.net/qccQZ/3/

    $("#field2").keypress(function(e){
        var f1 = $("#field1").val();
        var len = $(this).val().length;
        var str = String.fromCharCode(e.charCode)
        if(f1.charAt(len) != str) return false;
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html form with two input fields, in first one user puts
I have a usual login form consisting of two input fields, one for login,
I have a form with two input text fields: <input id=ModelName_test_0 name=ModelName[test][0] type=text> <input
I have a form with two text_fields: <input type=text id=post_name name=post[name] /> <input type=text
I'm trying to have two functions checking each form input, one for onchange() and
I have two forms: one that takes user information (name, birthdate, etc): formA. And
I have two fields <form action=insert.php method=post> Firstname: <input type=text name=firstname /> Lastname: <input
I have a very simple form with a name field and two submit buttons:
I have a two field HTML form for newsletter signup. One field is for
I have two functions one is hook and the other is filter. Hook function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.