TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abraham Olatubosun
NA
471
113k
How to Compute Two TextBox Using Jquery
Mar 23 2017 2:05 PM
Dear code masters,
I believe you are all in good health.
I need your Assistance once again, my challenge is as follows:
Let say i have a webform in
ASP.NET
, that have two Textbox's
Txt1
and
Txt2
Txt1 is for previou tempratureand and it is readonly, when the form load previous data from Database is loaded into
Txt1
so the user is expected to input current temprature into
Txt2
we want
Txt2
to validate
Txt1
if it is not a space and if it is greater than or equal to zero. If that happens then
Txt1 = Txt1 + Txt2 else
Txt1 = Txt2.
I use Jqeury as follows:
<script type=
"text/javascript"
src=
"Scripts/jquery-3.1.1.min.js"
></script>
<script type=
"text/javascript"
>
$(
function
() {
$(
'#<%=Text1.ClientID%>'
).blur(
function
sumN1() {
var
T = $(
'#<%=TextBox3.ClientID%>'
).val()
if
(T !=
""
&& T >= 0) {
$(
'#<%=Txt1.ClientID%>'
).val(+$(
'#<%=Txt1.ClientID%>'
).val() + +$(
'#<%=Txt2.ClientID%>'
).val());
}
else
{
$(
'#<%=Txt1.ClientID%>'
).val($(
'#<%=Txt2.ClientID%>'
).val());
}
})
})
</script>
this code works fine, if
Txt1 = 50
from load and the user input 10 in
Txt2
the result in
Txt1 = 60
, but the challange is when the user input the wrong figure 10 instead of 5 and the user change it, it add it up so
Txt1
became 65 but what we want is for
Txt1
to change to 55.
how can we impliment this with the above Jquery.
Thank you all
Reply
Answers (
3
)
how to make a project
How to extract XFA form field values using javascript