By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,319 Members | 1,963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,319 IT Pros & Developers. It's quick & easy.

compare text box values

parshupooja
100+
P: 159
Hey all I have two text boxes. I want to show message if text box1 value is not equal to textbox2

I have written this but it does not work


Expand|Select|Wrap|Line Numbers
  1. function ValidatePost()
  2. {
  3.  
  4.      if(document.getElementById("<%=txtsign.ClientID%>").value != document.getElementById("<%=txtId.ClientID%>").value)
  5.       {               
  6.                  alert("-------------------------");
  7.                  document.getElementById("<%=txtsign.ClientID%>").focus();
  8.                  return false;
  9.       }
  10. }
thanks
Jan 24 '08 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
How is this function called?
Jan 24 '08 #2

parshupooja
100+
P: 159
on change on of textbox1. textbox 2 gets value by itself on page load, so when user enter value in textbox 1 I want trigger validation.

thanks

How is this function called?
Jan 28 '08 #3

acoder
Expert Mod 15k+
P: 16,027
on change on of textbox1. textbox 2 gets value by itself on page load, so when user enter value in textbox 1 I want trigger validation.

thanks
So, is it something like:
[html]<input type="text" name="txtsign" id="somethingOrOther" onchange="ValidatePost()">[/html]

Just a note: please don't top-post. Thanks!
Jan 28 '08 #4

parshupooja
100+
P: 159
yes, i guess thats how it shd be, but it still does not work

So, is it something like:
[html]<input type="text" name="txtsign" id="somethingOrOther" onchange="ValidatePost()">[/html]

Just a note: please don't top-post. Thanks!
Jan 28 '08 #5

acoder
Expert Mod 15k+
P: 16,027
Have you checked that the IDs of the textboxes match with those used in the function? Are there any errors? If not, post your full code (if it's not too much) or a link to a test page.
Jan 29 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.