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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:57:45+00:00 2026-06-11T09:57:45+00:00

i am validating the text box value on following conditions It should be minimum

  • 0

i am validating the text box value on following conditions

  1. It should be minimum of 3 characters

  2. It should contain only alphabets

  3. It should contain at least one vowel

If all the conditions get matches I am enabling the submit button.
If any of the above case are not matched I am setting an error message to div named error.

Here is my code

$document.ready(function(){

 $('.tbox').focus(); // cursor in text box 
 $(':submit').attr("disabled",true); // disable generate button

    $('.tbox').focus(fucntion(){

        check_the_input()   
    }); 


    });

function check_the_input()
{

    var value = $(this).val();

    $('.tbox').bind('keyup blur',function(){ 
    $(this).val( $(this).val().replace(/[^a-z]/g,'') ); }

    if(value.length > 3)
    {
        if(value.indexOf('a') == -1 && value.indexOf('e') == -1 && value.indexOf('i') == -1 && value.indexOf('o') == -1 && value.indexOf('u') == -1)
        {
            $('#error').text("*Input must contain atleast one vowel");
            $(':submit').attr("disabled",true); 

        }
        else
        {
            $(':submit').attr("disabled",false);
        }

    }
    else
    {
        $('#error').text("*Input should be atleast 3 characters")
        $(':submit').attr("disabled",true); 
    }


    setTimeout(check_the_input,100);
}

I am facing following issues here:

  1. If I type input as aa99 the input changes to aa , but still the generated button is enabled.

  2. I am not getting the error at the time I type the text. Only after pressing tab or clicking mouse outside the textbox I am getting error.

  • 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-11T09:57:46+00:00Added an answer on June 11, 2026 at 9:57 am

    I would suggest rethinking the approach. Consider this simpler example:

    HTML:

    <form>
      <input type="text" id="myinput"/>
      <button id="submit" type="submit" disabled>Submit</button>
      <p class="error"></p>
    </form>
    

    jQuery:

    By using a function test and an object to store your validation filters your code becomes more obvious, more elegant and you get better performance and it’s easier to maintain for example to add new filters or more inputs.

    Demo: http://jsbin.com/ezatap/6/edit

    var $input = $('#myinput');
    var $error = $('.error');
    var $submit = $('#submit');
    var Filters = {
      min: {
        re: /.{3,}/,
        error: 'Must be at least 3 characters.'
      },
      char: {
        re: /^[a-z]+$/i,
        error: 'Must be only letters.'
      },
      vowel: {
        re: /[aeiou]/i,
        error: 'Must have at least one vowel.'
      }
    };
    
    function test(value, filters) {
      var isValid = false;
      for (var i in filters) {
        isValid = filters[i].re.test(value);
        $error.hide();
        $submit.prop('disabled', false);
        if (!isValid) {
          $error.show().text(filters[i].error);
          $submit.prop('disabled', true);
          break;
        }
      }
      return isValid;
    }
    
    test($input.val(), Filters);
    $input.on('keyup blur', function() {
      test(this.value, Filters);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following set up, a ddl (ddlProd, radBuyer) and autocomplete text box
Using the following simple text box as an example: <ComboBox IsEditable=True SelectedItem={Binding}> <ComboBoxItem>Angus/ComboBoxItem> <ComboBoxItem>Jane</ComboBoxItem>
I have the following text box control ; <asp:TextBox ID=txtAmount runat=server AutoPostBack=true Width=85px class=validate[ERExpenseTypeDaterequired,custom[float]]
I am validating value entered in textbox against database and wanted to show right
I'm validating a textbox for valid email with this: <asp:RegularExpressionValidator ID=RegularExpressionValidator1 ControlToValidate=txtMailCustom Text=Invalid address
I'm trying to use Rails validations for a form text box to see if
I'm validating a text field in my form as follows: $name = new Zend_Form_Element_Text('name');
I am using the following javascript for form validation: <script type=text/javascript> function validate_form (
I am trying to apply a style to a text box when the content
I have the following custom Validation.ErrorTemplate: <Setter Property=Validation.ErrorTemplate> <Setter.Value> <ControlTemplate> <DockPanel LastChildFill=True> <Label DockPanel.Dock=Bottom

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.