0

i have been trying to get this to work all day it seams like it should be pretty simple but i can't seam to get it to work i am not very good at this yet and im teaching myself so work with me =)

i have 2 inputs

    <input id="id1" type="text" name="os0" maxlength="200" value="Address">
    <br/>
    <input id="id2" type="text" name="os0" maxlength="200" value="Address">

all i am trying to do is confirm there both the same this is the jquery/JavaScript i am trying to use

    $('#id2').keyup(function() {
    if ($('#id1').attr('value') == $('#id2').attr('value')) {
    alert('true')} else { alert('false')}
    });

the way i read this it should do alert true if they match and alert false if they don't but this is not how it is working its returning true for both and i don't know how to fix it would love any help anyove could give me on this (keep in mind i am not very good at this)

1 Answers1

1

@ArunPJohny already pegged it, but here is the corrected code:

 $('#id2').keyup(function () {
     if ($('#id1').val() == $('#id2').val()) {
         alert('true');
     } else {
         alert('false');
     }
 });