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

  • Home
  • SEARCH
  • 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 7815645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:35:06+00:00 2026-06-02T05:35:06+00:00

I am using javascript validation for my input box from javascript-coder and it works

  • 0

I am using javascript validation for my input box from javascript-coder and it works fine on my non-ajax pages but when I use ajax to POST inputs the script runs through without stopping even if validation fails. I tried an example from here but when I tried the suggestion the validation didn’t work at all. In my ajax script I can get everything to work with jquery validation by simply putting this in before posting data:

var frm = $(this).closest('form');        
        if($(frm).valid()){

But I really want to stick with this validation library so I am hoping someone in the community more familiar javascript and maybe even this validation library can help me find an equivalent because I haven’t been able to find anything in all the documentation that allows you to test if validation failed or not before moving my ajax script forward.

My form:

<form method="post" name="send_message_frm" id="send_message_frm">
        <div style="margin-top:20px;"></div>
        <fieldset>
          <div class="clear"></div>
          <div style="margin-top:20px;"></div>
          <label>Product Group Name:</label>
          <input name="desc" class="text-input medium3-input required" type="text" id="desc" value="">
          <div style="color:red;" id='send_message_frm_desc_errorloc' ></div>
          <div style="margin-top:20px;"></div>
        </fieldset>
        <input name="user" class="text-input medium3-input" type="hidden" id="user" value="<?php echo $myid ; ?>">
        <div style="margin-top:20px;"></div>
         <input type="submit" id="send-message" name="submit" value="Send" class='button'  />
        <div style="margin-top:20px;"></div>
      </form>  
<script  type="text/javascript">


    var frmvalidator = new Validator("send_message_frm");
    frmvalidator.EnableOnPageErrorDisplay();
    frmvalidator.EnableMsgsTogether();
    frmvalidator.addValidation("desc","alnum","Only numbers and letters are allowed");
    frmvalidator.addValidation("desc","req","Please enter a description");


</script> 

My Ajax script:

<script type="text/javascript">

$(document).ready(function(){
    //Validate form....what can I put here to test if validation is completed properly????

    //onclick handler send message btn
    $("#send-message").click(function(){
        $(this).closest('form').submit(function(){
            return false;
        });
        var frm = $(this).closest('form');        

            $("#ajax-loading").show();
            var data = $(frm).serialize();
            $(frm).find('textarea,select,input').attr('disabled', 'disabled');            
            $.post( 
                    "productgroup_add.php", 
                    data, 
                    function(data){ 
                        $("#ajax-loading").hide();
                        $(frm).find('textarea,select,input').removeAttr('disabled');
                        $("#send_message_frm").prepend(data);
                    } 
           );
        }
    );
    });
</script>
  • 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-02T05:35:08+00:00Added an answer on June 2, 2026 at 5:35 am

    After reviewing the validation script, I discovered (as suspected) that it attaches the validation method to the form’s OnSubmit event handler, which sounds about right…

    this.formobj.onsubmit = form_submit_handler;
    

    But… it also attaches itself to the form object:

    this.formobj.validatorobj = this;
    

    which has a method that you can call to validate your form:

    if (!this.runAddnlValidations())
    

    To run the validations, it looks like you can just do something like:

    if(!document.forms[0].validatorobj.runAddnlValidations()) return;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Javascript to validate some code, and it works fine, but whenever
I would like to perform form validation using JavaScript to check for input field
I have some client-side JavaScript validation on a form. It works great. But I
I am using javascript unobtrusive validation. I have a view model that I am
I am done with validation using javascript for a form in PHP. When is
I want to do some client side validation using javascript in ASP.NET page. I
I have designed a webpage using HTML and client side validation using JavaScript.PHP for
I am having a great deal of trouble with client side validation using JavaScript
I am try to write some validation script using javascript and prototype. What I
I'm using ASP.NET MVC Validation. I want to know in my javascript functions whether

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.