473,467 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Removal of "undefined" keyword from the textbox

92 New Member
hello guys,
I am having mulitple textboxes, where numerals are fed and onBlur of each text box, the value gets added and is displayed in a text box at bottom. The total field is made readonly since we dont want the users to enter false values.

Now, if i enter a values in each text box it adds up dynamicaly and i can view the result/total in the readonly field.

Also if i delete the values in each text box the total gets decremented automatically, the problem here is when is delete all the values the total field will be automatically set to "Un-Defined". I need to get rid of this keyword since i dont want these type of values storing in the DB.

Your help would be much appreciated. Thanks in advance.
Oct 19 '09 #1
6 2372
hsriat
1,654 Recognized Expert Top Contributor
Do some validation before you add the number. Use parseInt().
Oct 19 '09 #2
chandhseke
92 New Member
See my code below:

c = new Number(Remove_Comma(document.frm.txt_1.value));
d = new Number(Remove_Comma(document.frm.txt_2.value));
e = new Number(Remove_Comma(document.frm.txt_3.value));

var Calc = c + d + e

document.frm.Total.value=roundNumber(Calc,2)

So while i enter the values in textbox a, b and c it automaically calculates and stores the result in total field.
Similarly, if i delete the values in each field the total values gets decremented anfd finally when all the values are deleted the total field sets to "Un-defined", which i dont to see, rather it should be 0. Please help
Oct 19 '09 #3
RamananKalirajan
608 Contributor
Just before adding all the three variables c, d and e.. Check wether its null

Expand|Select|Wrap|Line Numbers
  1. if(c==null||c==""||c=="null")
  2. {
  3.    c=0;
  4. }
like this do for all the three variables your problem will be solved.

Thanks and Regards
Ramanan Kalirajan
Oct 20 '09 #4
Dormilich
8,658 Recognized Expert Moderator Expert
@RamananKalirajan
wouldn’t
Expand|Select|Wrap|Line Numbers
  1. c = c || 0;
do the same? (except for "null", which is a string)
Oct 20 '09 #5
ivosilva
17 New Member
Hello, chandhseke.

You could use isNaN to check if the value is a number. If not, then set to 0.

Best regards!
Oct 20 '09 #6
chandhseke
92 New Member
Hi Folks,

Many thanks for posting your reply. My problem got resolved!!. It is working fine now.

Best Regards!
Oct 20 '09 #7

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

Similar topics

1
by: JKop | last post by:
Would you classify the following code as "Undefined Behaviour" or as "Non- portable"? signed main() { signed char chedder = 130; } Relevant information:
13
by: Don Vaillancourt | last post by:
What's going on with Javascript. At the beginning there was the "undefined" value which represented an object which really didn't exist then came the null keyword. But yesterday I stumbled...
25
by: Nitin Bhardwaj | last post by:
Well, i'm a relatively new into C( strictly speaking : well i'm a student and have been doing & studying C programming for the last 4 years).....and also a regular reader of "comp.lang.c" I...
23
by: Ken Turkowski | last post by:
The construct (void*)(((long)ptr + 3) & ~3) worked well until now to enforce alignment of the pointer to long boundaries. However, now VC++ warns about it, undoubtedly to help things work on 64...
49
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On...
9
by: Klaus Johannes Rusch | last post by:
IE7 returns "unknown" instead of "undefined" when querying the type of an unknown property of an object, for example document.write(typeof window.missingproperty); Has "unknown" been defined...
6
by: teddysnips | last post by:
In my application I need to allow users to cut 'n' paste stuff from various sources, some of which might include dodgy characters such as "<". Natch, IE interprets these as potentially dangerous...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.