there are is an in the following code. I have no idea why i got this error
this function should allow numeric entry backspace,shift, delete,enter, arrow keys, point/dot,
On line #7 on my code below
Uncaught TypeError: Object [object Object] has no method 'ForceNumericOnly'
what is wrong with this code?
Here is my code
- $(function () {
-
- $('#Reservation_id').change( calculateRemainingBalance );
-
-
- $("#firstVal, #secondVal").keyup( calculateRemainingBalance );
- $("#firstVal, #secondVal").ForceNumericOnly();
-
- $('#first').change(showFirst);
- $('#second').change(showSecond);
- if (Number( $('#Reservation_id').val() ) > 0) {
-
- $('#finishPrint').show();
-
- } else {
- $('#CalculatePanel').hide();
- $('#finishPrint').hide();
- }
- showFirst();
- showSecond();
-
- $('#payCredits').click( function(e){
- e.preventDefault();
-
- var formData = $('#makePaymentForm').serialize();
- submitForm(formData);
- });
-
- $.fn.ForceNumericOnly =
- function ForceNumericOnly() {
- return this.each(function () {
- $(this).keydown(function (e) {
- var key = e.charCode || e.keyCode || 0;
- // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY, percentage
- return (
- key == 8 ||
- key == 9 ||
- key == 46 ||
- key == 110 ||
- key == 190 ||
- (key == 16 && key == 53) ||
- (key >= 37 && key <= 40) ||
- (key >= 48 && key <= 57) ||
- (key >= 96 && key <= 105));
- });
- });
-
- };
- function availableOpenCredits(){
- id = $('#Reservation_id').val();
-
- due = $('#totalOwe_' + id).val();
-
- if(Number(due) > 0){
- return true;
- } else {
- return false;
- }
-
- }
- function calculateRemainingBalance() {
- var first = 0, second = 0, total = 0, due = 0, id = 0;
- id = $('#Reservation_id').val();
- first = $('#firstVal').val();
- second = $('#secondVal').val();
- due = $('#totalOwe_' + id).val();
- cuID = $('#customerID_' + id).val();
-
- $('#Paying_Res_id').val(id);
- $('#Paying_Res_Total').val(due);
- $('#payingCustomerID').val(cuID);
-
- if( availableOpenCredits() ){
- $('#CalculatePanel').show();
- } else {
- $('#CalculatePanel').hide();
- }
- if (Number(id) > 0 && Number($('#totalOwe_' + id).val()) > 0) {
- $('#CalculatePanel').show();
- $('#finishPrint').show();
- } else if ( Number(id) > 0 && Number($('#totalOwe_' + id).val()) == 0){
- $('#finishPrint').show();
-
- } else {
- $('#CalculatePanel').hide();
- $('#finishPrint').hide();
- }
- $('#customerID').val(cuID);
- first = Number(first);
- second = Number(second);
- due = Number(due);
- total = due - (first + second);
- total = total.toFixed(2);
- $('#balance').val(total);
- }
- function showSecond() {
- if ($('#second').val() == 'credit' || $('#second').val() == 'check') {
- $('#dueDateSecond').show();
- } else {
- $('#dueDateSecond').hide();
- }
- }
- function showFirst() {
- if ($('#first').val() == 'credit' || $('#first').val() == 'check') {
- $('#dueDateFirst').show();
- } else {
- $('#dueDateFirst').hide();
- }
- }
- function submitForm(formData) {
- $.ajax({
- type: 'POST',
- url: 'payCredit.php',
- data: formData,
- dataType: 'json',
- cache: false,
- timeout: 7000,
- success: function(data) {
-
- $('#additionlResult').removeClass().addClass((data.error === true) ? 'errorBox' : 'passBox').html(data.msg).fadeIn('fast');
-
- if ( $('#additionlResult').hasClass('passBox') ) {
-
-
- id = $('#Reservation_id').val();
- $('#totalOwe_' + id).val(data.remainingBalance);
-
- $('#makePaymentForm')[0].reset();
- $('#balance').val(data.remainingBalance);
-
- if(Number(data.remainingBalance) == 0 ){
- $('#CalculatePanel').hide();
- }
- }
-
- },
- error: function(XMLHttpRequest, textStatus, errorThrown) {
-
- $('#additionlResult').removeClass().addClass('errorBox')
- .html('<p>There was an<strong> ' + errorThrown +
- '</strong> error due to a<strong> ' + textStatus +
- '</strong> condition.</p>').fadeIn('fast');
- },
- complete: function(XMLHttpRequest, status) {
- //$('#makePaymentForm')[0].reset();
- }
- });
- };
- });
- $(function(){
- $( "#dueDateFirstVal" ).datepicker({
- changeMonth: true,
- dateFormat: "dd-mm-yy",
- yearRange: "c-0:c+2",
- minDate: new Date(),
- changeYear: true
- });
-
-
- $( "#dueDateSecondVal" ).datepicker({
- changeMonth: true,
- dateFormat: "dd-mm-yy",
- yearRange: "c-0:c+2",
- minDate: new Date(),
- changeYear: true
- });
- });