Solved

Input validation during onChange results NAN

Posted on 2013-02-01
7
532 Views
Last Modified: 2013-02-19
Team,
am facing an issue during my edit page where i have a text box gives me a trouble during validation.

I am calling an onchangeTotal() function , when ever there is a change in value via onchange event.  when ever there is a text entered , the total column is updated dynamically. i would like to prevent it . do all my validation after i tab out the cell.
because when there is an invalid value entered , i need to print ***** in the total section based on the value.

i have attached a screen shot where it updates the total section with Nan.

Please help.
validate.JPG
0
Comment
Question by:Easwaran Paramasivam
  • 5
  • 2
7 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 38845559
......do all my validation after i tab out the cell.
Use onblur instead of onchange.
0
 
LVL 16

Author Comment

by:Easwaran Paramasivam
ID: 38847915
yeah. am sorry. i should have mentioned in the above query itself. yeah i tried with onblur event as well. no luck.

Thanks
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 38848036
Can you share your code that didn't work...it seems some kind of type conversion issue..
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 16

Author Comment

by:Easwaran Paramasivam
ID: 38861821
Sorry for the delay.

I have added the code snippet for the input text:

input type="text" class="inputs txtr" maxLength="12" name="txt_${participant.ssn}_${plan.planId}_${contractID}_${sourceID}_${source.UIName}"                                                                                                      value="${source.contributionAmt}" id="id${contractID}_input_${sourceID}_${source.UIName}" relSrc="${sourceID}_${source.UIName}"                                                                                                 relCtr="${contractID}"  onchange="javascript:calculateTotal('${contractID}','${sourceID}','${source.UIName}')" />
                                                                                    </div>

I have uploaded the JSP page as HTML and JS script page as well.

Please do let me know if you need any additional info to dig this issue.

Thank you
EditJSP.html
EditJS.js
0
 
LVL 16

Author Comment

by:Easwaran Paramasivam
ID: 38890359
Team,
I have an validation in place to report when we enter invalid value in the text box.
various conditional check to NAN & < 0 and so on.
The point here is that when i enter the value in the text box and tab out it , validation is not occurring and when i enter value and click on any place in the web page it works and prints **** in the total section.
attached the screen print to have some details on the issue.

Can someone point out the issue with the script?.

Thanks
validation-issue.JPG
0
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 0 total points
ID: 38890965
Team,
i was able to figure whats is going on in my JS function and was able to fix it.
The root cause was one of the CSS class and my existing JS file has a check

// column total
                  var columnTotal = 0;
                  $( '.rowaggregate' ).each( function()
                  {
                        columnTotal += parseFloat( $( this ).html() );
                  } );
It was very frustrating to find out this issue and happy to resolve it. Thanks a lot for this great forum.
0
 
LVL 16

Author Closing Comment

by:Easwaran Paramasivam
ID: 38904782
I was able to resolve the issue on my own. please close the question.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now