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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:46:10+00:00 2026-05-25T19:46:10+00:00

I have a form that submits to a jQuery plugin I’ve written and used

  • 0

I have a form that submits to a jQuery plugin I’ve written and used on several projects, and I’m trying to expand its functionality. I’ve never had any issues with it until now, when I decided to add optional fields to my form. All input text fields on my form are pre-populated via another jQuery function with brief instructions, which disappear when the field receives focus and the user begins typing.

The problem is, the optional inputs post their pre-populated values if the user does not enter his own, and in this case my jQuery plugin returns a “missing ) after argument list” error. The error does not appear if the user fills in all fields.

Here is the code I’m using:

$(document).ready(function(){
    $("#contact-submit").click(function(){
        var valid = '';
        var isr = ' is required.';
        var fname = $("#cfname").val();
        var company = $("#ccompany").val();
        var email = $("#cemail").val();
        var phone = $("#cphone").val();
        var location = $("#clocation").val();
        var website = $("#cwebsite").val();
        var design = $("#cdesign:checked").val();
        var security = $("#csecurity:checked").val();
        var social = $("#csocial:checked").val();
        var seo = $("#cseo:checked").val();
        var video = $("#cvideo:checked").val();
        var presence = $("#cpresence:checked").val();
        var customers = $("#ccustomers:checked").val();
        var showcase = $("#cshowcase:checked").val();
        var campaign = $("#ccampaign:checked").val();
        var ecommerce = $("#cecommerce:checked").val();
        var digital = $("#cdigital:checked").val();
        var sec = $("#csec:checked").val();
        var vid = $("#cvid:checked").val();
        var gseo = $("#cgseo:checked").val();
        var other = $("#cother:checked").val();
        var budget = $("#cbudget").val();
        var time = $("#ctime").val();
        var os = $("#cos").val();
        var comment = $("#ccomment").val();
        if (!email.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
            valid += '<br />A valid Email'+isr;
        }
        if (fname.length<1) {
            valid += '<br />Your name'+isr;
        }
        if (phone.length<13) {
            valid += '<br />A 10-digit phone number of the format (xxx)xxx-xxxx'+isr;
        }
        if (phone.length>13) {
            valid += '<br />A 10-digit phone number of the format (xxx)xxx-xxxx'+isr;
        }
        if (valid!='') {
            $("#contact-message").fadeIn("slow");
            $("#contact-message").html("Error:"+valid);
        }
        else {
            var datastr ='fname=' + fname + '&company=' + company + '&email=' + email + '&phone=' + phone + '&location=' + location + '&website=' + website + '&design=' + design + '&security=' + security + '&social=' + social + '&seo=' + seo + '&video=' + video + '&presence=' + presence + '&customers=' + customers + '&showcase=' + showcase + '&campaign=' + campaign + '&ecommerce=' + ecommerce + '&digital=' + digital + '&sec=' + sec + '&vid=' + vid + '&gseo=' + gseo + '&other=' + other + '&budget=' + budget + '&time=' + time + '&os=' + os + '&comment=' + comment;
            $("#contact-message").css("display", "block");
            $("#contact-message").html("Submitting...");
            $("#contact-message").fadeIn("slow");
            setTimeout("send('"+datastr+"')",2000);
        }
        return false;
    });
});
function send(datastr){
    $.ajax({    
        type: "POST",
        url: "plugins/hm_custom/mail-consult.php",
        data: datastr,
        cache: false,
        success: function(html){
        $("#contact-message").fadeIn("slow");
        $("#contact-message").html(html);
        setTimeout('$("#contact-message").fadeOut("slow")',2000);
    }
    });
}

What makes it even more confusing, is that if I reduce the number of inputs back to my original six text fields, no errors are thrown, even if I fail to insert text into the optional fields. I’m sure that my code is much more complex than it has to be, it’s a work in progress and I’m slowly learning how to condense it bit by bit. I have to think my problem must be a syntax error that is being tripped conditionally, but I am very new to Javascript and jQuery, so I have no clue.

Any ideas?

  • 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-25T19:46:11+00:00Added an answer on May 25, 2026 at 7:46 pm

    Your issue, i think, is this line:

    setTimeout("send('"+datastr+"')",2000);
    

    You are building a string that defines the function name, and by adding in the dataStr, you are building an invalid name.

    If you use a closure instead of a hardcoded string, this should alleviate the issue:

    setTimeout(function() { send(dataStr); },2000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that is using jQuery Validate plugin for client side validation,
I have a form that validates using the jQuery plugin: Validation, v1.9.0. The validation
I have a form that i am validating using jquery the validation plugin. What
I have a form with a Jquery plugin requirement that creates a form input
I have a page that has a form using this ajaxForm jQuery plugin .
I have a form that uses jQuery to submit an ajax post and it
I have a form that submits a search for blogs on my site via
i have a form that submits data to a database, i have a function
i have a PHP contact form that submits data, and an email...: <?php $dbh=mysql_connect
I have a web form that collects information and submits it to a cgi

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.