Comment jquery code

i finally got his page done with all the help from you experts
could someone comment this code, its over my head?
$('#in').on('input propertychange', function () {
    var text = $(this).val();
    var t2 = text.replace(/[^\d\.]/g, "")
        .replace(/\./, "z")
        .replace(/\./g, "")
        .replace(/z/, ".");
 
  t2 = ""||/^(\d+)?([.]?\d{0,2})?$/.test(text)===false?t2 = "Input Numbers Only":t2="";
   
    if(t2==="Input Numbers Only"){alert(t2);}


 $('#in').on('keyup', function() {
                    if ($('#in').val().length > 0) {
                            var strValue = $('#in').val();
                            if (strValue.indexOf('.') > -1) {
                                    if (strValue.split('.')[1].length > 1) {
                                            $('#in').val(strValue.substring(0, strValue.length - 1));
                                    }
                            }
                            var value = parseFloat($('#in').val());
                            if (value > 90000) {
                                    value = Math.floor(value);
                                    value /= 10;
                                    value = Math.floor(value);
                                    value = value.toFixed(0);
                                    $('#in').val(value);
                                    $('#measureLabel').removeClass('Require');
                            }
							roofAreaVal = $('#selectPitch option:selected').val();
                            if (value < 100) {
                                    $('#measureLabel').addClass('Require');
									calc(roofAreaVal); // call calc fnction
                            } else {
                                    $('#measureLabel').removeClass('Require');
									calc(roofAreaVal); // call calc fnction
                            }
                    }
            });

Open in new window

isnoend2001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
This line is wrong

 t2 = ""||/^(\d+)?([.]?\d{0,2})?$/.test(text)===false?t2 = "Input Numbers Only":t2="";

should be

 t2 == ""||/^(\d+)?([.]?\d{0,2})?$/.test(text)===false?t2 = "Input Numbers Only":t2="";
0
GaryCommented:
The regex is checking the input is a number with only one period (full stop)

The keyup function checks if there is more than one period in the value, if there is then it removes everything after the second period.


If value is greater than 90000 then round the number down to the nearest integer, divide by 10, round down again, and set the inputs value to this new number

The rest is pretty much self explanatory
0
isnoend2001Author Commented:
thanks Gary
I made the change and it still works
http://roofgenius.com/test2.asp
as far as The rest is pretty much self explanatory, maybe to you but not to me
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

GaryCommented:
What other bits don't you understand
0
isnoend2001Author Commented:
var value = parseFloat($('#in').val());
just about every line
0
isnoend2001Author Commented:
i was hoping to have a comment on each line like this:
  // CHECK FOR A CHANGE IN THE DROP DOWN MENU
     $('#selectPitch').change(function () {
        $('#selectPitchLabel').addClass('Require'); // RESET LABEL
         var roofAreaVal = $(this).val();  // GET VALUE OF DROPDOWN xnew 07-12-14        
         var roofAreaTxt = $('#selectPitch option:selected').text();  //GET VALUE OF THE TEXT OF THE DROP DOWN
         var rat = roofAreaTxt.split(' ');  // CONVERT THE TEXT OF THE DROP DOWN TO AN ARRAY. REQUIRED TO REVERSE USAGE IN HE MESSAGE
         var newAreaTxt = rat[1] + ' ' + rat[0];  // REVERSE THE ORDER OF THE TEXT
             $('#Result').text(roofAreaTxt);   // 7-12-2014 Q_28474675
         if (roofAreaVal != 0) {  // CHECK TO MAKE SURE THERE IS A VALUE IN THE DROP DOWNxnew 07-12-14
              $('#selectPitchLabel').removeClass('Require');//xnew 07-12-14
             
             calc(roofAreaVal);  // RUN THE FUNCTION TO MAKE THE CALCULATIONS
             $('#roofMesg').val('Roof ' + newAreaTxt + ' added ' + roofAreaVal);
         }

     });
0
GaryCommented:
$('#in').on('input propertychange', function () {
	
     var text = $(this).val(); //Get input value

     Replace anything not a number and replace . with z
     var t2 = text.replace(/[^\d\.]/g, "")
         .replace(/\./, "z")
         .replace(/\./g, "")
         .replace(/z/, ".");
  
   // if the value is blank or fails the number/single period regex then set t2 = Input Numbers Only
   t2 == ""||/^(\d+)?([.]?\d{0,2})?$/.test(text)===false?t2 = "Input Numbers Only":t2="";
    
     //if t2= Input Numbers Only then make an alert
     if(t2==="Input Numbers Only"){alert(t2);}


  $('#in').on('keyup', function() {
                     if the input with ID [i]in[/i] is greater than 0
                     if ($('#in').val().length > 0) {
                             // Get the value
                             var strValue = $('#in').val();
                             
                             //Check if there is a period
                             if (strValue.indexOf('.') > -1) {
                                     // check if there is more than 1 period and remove everything after and including it.
                                     if (strValue.split('.')[1].length > 1) {
                                             $('#in').val(strValue.substring(0, strValue.length - 1));
                                     }
                             }
                             // Make sure the input value is a number
                             var value = parseFloat($('#in').val());
                             if (value > 90000) { //if greater than 90000
                                     
                                     value = Math.floor(value);// round down to a whole number
                                     value /= 10;//Divide by 10
                                     value = Math.floor(value);// round down to a whole number again
                                     value = value.toFixed(0);//Make sure is a whole number (not needed)
                                     $('#in').val(value);// Set the input to the new value
                                     $('#measureLabel').removeClass('Require');// Remove the [i]Require[/i] class
                             }
                                           roofAreaVal = $('#selectPitch option:selected').val();// Get the dropdown value
                             if (value < 100) { //if dropdown is less than 100
                                     $('#measureLabel').addClass('Require'); // Add the [i]Require[/i] class
                                                       calc(roofAreaVal); // call calc fnction
                             } else {
                                     $('#measureLabel').removeClass('Require');// Remove the [i]Require[/i] class
                                                       calc(roofAreaVal); // call calc fnction
                             }
                     }
             }); 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
isnoend2001Author Commented:
Yes Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.