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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:36:06+00:00 2026-05-31T06:36:06+00:00

function validate() { var textbox= $(#inputtextbox).val(); var match = /^([a-zA-Z0-9]{1,})$/; if(!match.test(textbox)) { $(#dataError).text(‘Min 1

  • 0
function validate()
    {
     var textbox= $("#inputtextbox").val();
     var match = /^([a-zA-Z0-9]{1,})$/;
     if(!match.test(textbox)) {
     $("#dataError").text('Min 1 alpha numeric characters and space allowed.').fadeOut(5000);
    return false;
    }

var textbox= $("#inputtextbox").val();
     var match = /^([a-zA-Z0-9]{1,})$/;
     if(!match.test(textbox)) {
     $("#dataErr").text('Min 1 alpha numeric characters and space allowed.').fadeOut(5000);
    return false;
    }
}

I’ve a form and two text boxes.I’m validating two text boxes.Say,when i do not fill both text boxes and click submit button,it is only print the error message for first textbox.
When i fill every thing properly in first text box and i do not fill any thing in second text,now if i submit,it is showing error message for second text box,why is it not showing the message,when both not filled.

Thanks in advance!

  • 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-05-31T06:36:07+00:00Added an answer on May 31, 2026 at 6:36 am

    try this

    <input id="box_1" class="textbox" value="" />
    <span></span>
    
    <input id="box_2" class="textbox" value="" />
    <span></span>
    
    $('#form').submit(function(){
    
    var valid = validate();
    
    if(valid)
    {
       //do submit
    }
    
    });
    
    
    function validate()
        {
    
         var result = true;
    
         $('.textbox').each(function(){
    
         var textbox= $(this).val();
    
         var text_id = $(this).attr('id');
    
         if(text_id = 'box_1')
         {
             var match = /^([a-zA-Z0-9]{1,})$/;   
         }
         else if(text_id = 'box_2')
         {
             var match = /^([a-zA-Z0-9]{1,})$/;   
         }
    
         if(!match.test(textbox)) {
            $(this).next('span').text('Min 1 alpha numeric characters and space allowed.').fadeOut(5000);
            result = false;
            }
        });
    
    return result;
    
        }
    

    UPDATE

    function validate()
        {
    
         var valid = true ;
    
         var textbox= $("#inputtextbox_1").val();
         var match = /^([a-zA-Z0-9]{1,})$/;
         if(!match.test(textbox)) {
         $("#dataError_1").text('Min 1 alpha numeric characters and space allowed.').fadeOut(5000);
        valid  = false;
        }
    
    var textbox= $("#inputtextbox_2").val();
         var match = /^([a-zA-Z0-9]{1,})$/;
         if(!match.test(textbox)) {
         $("#dataErr_2").text('Min 1 alpha numeric characters and space allowed.').fadeOut(5000);
        valid = false;
        }
    
       return valid;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can do this jQuery.fn.validate = function(options) { var defaults = { validateOPtions1 :
to custom validate an input i wrote a script: function cardNumberCheck(value, element) { var
Markup: <input type=text name=email /> Code: $(':text').focusout(function(){ $(this).validate(function(){ $(this).attr('name'); }); }); Plugin: (function($){ $.fn.validate
My validation function looks like that. var fname = $(#fname).val(); var lname = $(#lname).val();
I need to validate a textbox, so it's value consist of 10 characters (not
I need validate the dynamically appended input text box for the below code $(#btnadd).click(function()
I am using this home-made function to validate text fields, but for some reason,
I'd like to have a textbox validate that the text in it is in
yet I didnt find a jquery function that validate value to be a future
I have done various tests and I have found that the jQuery validate function

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.