Take the 2-minute tour ×

I am using jquery validate to check the existing phone number in my database. I am using jquery validate remote attribute for this.

remote: {
    url: "ajax-checkmobile.php",
    type: "post",
    data: {
      cust_id: function() {
        return $("#cust_id").val();

However this is preventing the submit value being passed on form submission via POST.

<input name="Submitcustdata" type="submit" class="chromeButton" id="Submitcustdata" value="Edit Customer" /></td>

After removing the above code submit value gets passed correctly. Any idea what could be preventing value from being passed

share|improve this question
jquery is jquery not php. do not put random keywords. –  Marcin Orlowski Aug 31 '12 at 16:34
@WebnetMobile.com he wrote PHP because he is using jquery to make an ajax request to PHP, which is relevant for some. –  Kristian Aug 31 '12 at 16:35
the problem describes issue on JS side only. the fact url points to php script is irrelevant. –  Marcin Orlowski Aug 31 '12 at 16:37
add comment

2 Answers

validate stops the post from happening from occurring in order to validate. that is by design.

so, if its not submitting, then its thinking that the field is invalid, i'm guessing.

share|improve this answer
add comment

I have developed the following code, which I use in the context of submiting forms using AJAX. This is not exactly your case, but the same code will make your <input type="submit"> value to be submitted:

function submit_click() {
    var $input = $(this);
    var name = $input.attr('name');
    if (typeof name == 'undefined') return;
    var value  = $input.attr('value');
    var $form  = $input.closest('form');
    var $hidden = $('<input type="hidden" />').attr('name', name).attr('value', value);
    $form.find('input[type=hidden][name="' + name + '"]').remove();

$(document).on('click', 'form.ajax input[type=submit]', submit_click);

I use the class="ajax" in the form element to activate this code. You can change according to your needs.

What it does? It creates a hidden form input with the same name and value of the clicked submit input. So, when the post happens programatically later, the value is properly submitted.

Ah, you asked what could be preventing value from being passed... the validation plugin catches the form submission, and performs its stuff. After validating, it triggers the form submission. When this happens, it is not the <input> element click which is trigerring the form submission anymore. It is the JavaScript code of the plugin. So, the "<input>" click event is lost. This is why it is not submitted. (Makes sense? If this explanation is not well written, let me know.)

share|improve this answer
add comment

Your Answer


