Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Ajax jQuery
Hi
I want to compare two variables in jQuery, but I do not.
Where is the problem with your comment
 
$(document).ready(function(){
var x=document.getElementById("demo")
x.innerHTML=Math.floor((Math.random()*52)*01087);
});
function valid(){
	var x=document.getElementById("demo");
	var y=document.getElementById("txtcode");
	if(x==y)
	{alert("ok");
	return false;
	}
	else
	{alert("nok");
	return false;
	}
	}
Posted 15-Mar-13 1:46am
Comments
sri senthil kumar at 15-Mar-13 6:55am
   
Your checking two object i think thats the issue... What you want to compare and what control(div, textbox, hiddenfield etc.,) is that?
bcsilent at 15-Mar-13 6:57am
   
Thank you dear friend:
Yes two text box fields
Sergey Alexandrovich Kryukov at 17-Mar-13 0:20am
   
Please don't post non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership. And the fact you even self-accepted on formally is just outrageous, a sure way for a ban. I hope you won't do it after this warning.
 
Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

var x=document.getElementById("demo").value;
var y=document.getElementById("txtcode").value;
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 15 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100