Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9001217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:24:25+00:00 2026-06-16T00:24:25+00:00

I am writing a jquery function to check if user input contains letters instead

  • 0

I am writing a jquery function to check if user input contains letters instead of numbers. Im just trying to get the basic functionality working and I am using an alert box to test this. The test should be displaying the alert regardless of what is entered. It works when numbers are entered, but any other character entered does not fire the alert,. Any ideas what is going on here?

The form is broken into fieldsets contained in divs, which pop-up as overlays. The function is called whenever the user tries to close a pop-up window,. Not that this should cause a problem?

Here is the test function:

function validateItem(item){
var fvalue = $(item).val();
alert(fvalue);
return false;  }

Here is a sample table item

<tr>
<td class="td_thumbs">
    <div>
        <a class="fancybox" data-fancybox-group="vinyl-banners" href="img/products/vinyl-corporateblue.jpg"> <img src="img/products/thumbs/vinyl-corporateblue-thumb.png" alt="vinyl c-blue"/></a>
        <label>Corporate Blue</label>
    </div>
</td>
<td>6</td>
<td>
    <input id="vinyl-blue" type="text" max="6" min="0" value="0"/>
</td>
</tr>

The calling function,

//iterate through each table
    $('table').each(function() {

        $thisTable = $(this);

        //iterate through each input
        $(this).find('input').each(function() {
            var $this = $(this), i_value = $this.attr('value'),
                itemLabel = $this.closest('tr').find('label').html();
            //if any items have a positive value
            if (i_value > 0) {
                //we want to grab the heading for these items
                setHeading = true;

                //validate item
                if(validateItem($this)){//if quantities are valid
                  //build list of items of this type
                 $this.css({
                      'border':'1px solid #ddd',
                      'background-color' : '#efefef'
                      });
                      items += '<li>' + i_value + 'x ' + itemLabel + '</li>';
                }
                else{//invalid quantity
                  $this.css({
                      'border':'1px dashed #F00',
                      'background-color' : '#f7d2d4'
                      });

                      errorFlag = true;
                      //exit item and table loops    
                      return false;                  
                }//end validate                

            }//end value check
        });//end input iteration
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:24:25+00:00Added an answer on June 16, 2026 at 12:24 am

    Found the issue! The function was called within the following..

    if (i_value > 0) {
    

    which meant it was only called when a number was input. I placed the call outside of this if statement and it works as expected, so the solution was to change

    if(i_value > 0)
    

    to

    if(i_value != 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Writing a jquery function to check whether password user enters is already in use.
Im writing some logic in JavaScript using jquery, where i must check the input
I'm writing a jQuery function where I'd like to access both the native size
I'm writing a jQuery plugin , which similar to this, $(this).each(function(){ $el = $(this).find('.el')
I am writing a function that well keep the user in lightbox images while
Ive been writing a simple jquery function that turns a div with a list
I'm writing a little jQuery extension that prevents a user from double clicking on
I am writing some code where the user can check if a username already
I just have started writing AJAX functions using jquery. Here i am calling myfunction()
I'm writing jQuery code where I need to check if link is an image.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.