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 7782655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:36:35+00:00 2026-06-01T19:36:35+00:00

I am using wordpress and trying to throw a message when the value for

  • 0

I am using wordpress and trying to throw a message when the value for a text input is greater than 40..

<input type="text" name="quantity" size="2" value="<?php echo wpsc_cart_item_quantity(); ?>" />

Now i want to throw a message (alert) when this text field contains value greater than 40 and also want to reset its value to ”
My wordpress theme uses jquery 1.71
I am doing the following:

jQuery("input[type='text'][name='quantity']").change(function() {
if (this.val >= 41) {
    alert("To order quantity greater than 40 please use the contact form.");
    this.val == '';
    this.focus();
    return false;
}
});

Thanks.​

  • 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-01T19:36:37+00:00Added an answer on June 1, 2026 at 7:36 pm

    You need in first place to wrap this with the $ function, since this is the DOM element returned by the selection query and not a jQuery object, and the val() function is not available on that kind of object.

    Also, you need to call the val() function with parenthesis, otherwise you’re working on the body of the function, not the value it returns.

    Finally, there is a typo on the assignment statement. You should at least do this.val = '', but that won’t work since val is a function, not a variable. Working code should look like this:

    $("input[type='text'][name='quantity']").change(function() {
        if ($(this).val() >= 41) {
            alert("To order quantity greater than 40 please use the contact form.");
            $(this).val('');
            $(this).focus();
        }        
    });    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to post to WordPress using curl via PHP - I'm posting using
I am trying to post some java code snippets on wordpress.com using the following
I'm trying to call WordPress's 'the_time' using a conditional statement that checks the category.
I can't figure this out for the life of me... Using wordpress trying to
I am using wordpress and am trying to link to the stylesheet: <link rel=stylesheet
I am using WordPress Version 2.9.2 for my blog.when i am trying to include
I have a new php page and I'm using wordpress for my website. From
I'm using a wordpress theme that I built and I'm trying to get a
So I'm trying to debug a somewhat confusing problem. I'm using a Wordpress plugin
Im trying to output or create json using wordpress posts data coupled with meta_key

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.