Click here to Skip to main content
15,892,253 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I have 4 asp textboxes in that 3 are we can enter the integer Values 4 th textbox is read only.
For example In 1st Textbox they entered the value is 20.
then 2nd textbox allow up to 20 at this case remaining two textboxes i need to prepopulate 0(Zero).
In second case the can enter 2 nd textbox vlaue is 15 3rd textbox value is 3 then
4 th textbox should prepoulate remaing '2'.
finally the sum of three(2nd,3rd,4th)textboxes values should match with 1st texbox value ...........
Please help me any one ..
Posted
Comments
Malli_S 28-Sep-12 7:55am    
Show up your code. What did you try? Where you stuck?
ZurdoDev 28-Sep-12 8:17am    
What's the problem?

1 solution

You can use following javascript function:

JavaScript
function Matchvalues()
{
  var value1 = document.getElementById('TextBox1').value;
  var value2 = parseInt(document.getElementById('TextBox2').value) +
               parseInt(document.getElementById('TextBox3').value) +
               parseInt(document.getElementById('TextBox4').value);

  if (value1 != value2) {
    alert('value in 1st TextBox and sum of Textbox2,Textbox3,Textbox4 are not matched');
    return false;
  }
  else {
    alert('value in 1st TextBox and sum of Textbox2,Textbox3,Textbox4 are matched');
    return true;
  }

}


call this function on OnClientClick event of a button.

Regards,
Bhushan Shah
 
Share this answer
 
Comments
BalaMahesh 29-Sep-12 1:05am    
4th Textbox value must should we can prepopualte because it is read only.
no need of entering any value in 4th textbox.
even zero also we can prepopulate.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900