Jquery: how to validate the value already exists in dynamic text boxes
source link: https://www.codesd.com/item/jquery-how-to-validate-the-value-already-exists-in-dynamic-text-boxes.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Jquery: how to validate the value already exists in dynamic text boxes
I am using jquery to create a dynamic text boxes and and also implement the auto complete for each text box added but i dnt know how to compare first text box and second text box in distinct value. for example
<input type='text' id='first' value='master' />
<input type='text' id='first1' value='master' />
please check this link here and guide me right path to achieve this. thanks in advance
If I understood your question correct, here is a code to answer your question:
<input type='text' id='first' value='master' />
<input type='text' id='first1' value='master' />
<input type="button" onclick="compare()" value="compare">
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
function compare() {
console.log("reading values <" + $('#first').val() + "> and <" + $('#first1').val() + ">");
if ( $('#first').val() == $('#first1').val() ) {
console.log("They are equal.");
} else {
console.log("They are not equal.");
}
}
</script>
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK