Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Validate Remote is failing. Can't submit form
    primarykey
    data
    text
    <p>I have what used to be a working form validation, including the remote check of a username as available. we've added a lot of other javascript to the script.js file and at some point recently the remote part of this broke. There is only one form field being checked by validate, the new_name field. It is required (works) and must be available (doesn't work).</p> <p>Here is the jQuery:</p> <pre><code> $('#nickname_form').validate({ rules: { new_name: { required: true, remote: { url: '/api/screenname_unique/', type: 'post' } } }, messages: { new_name: { required: 'Please choose a Forum Username.', remote: 'That Username is already taken or contains invalid characters.' } } }); </code></pre> <p>As I said the above used to work, with no changes. I've checked the rest of the script.js file and no errors are showing up. Also, in the site, we're not seeing JS errors anywhere. If I remove the remote portion of the above code, the required check works and the form will submit when there is a value in the field. </p> <p>With remote in place, the form will not submit, and whether the ajax response from the remote call is true or false, there is no jQuery validate error message shown. Here is the page called by remote. It works fine as far as the response it is giving for a given value:</p> <pre><code>&lt;?php header('Content-type: application/json'); //get the post value $screen_name = $_POST['new_name']; //get their member_id $member_id = $this-&gt;EE-&gt;session-&gt;userdata['member_id']; //return false if no screen_name provided if((!$screen_name) || (!$member_id)) { echo json_encode(false); exit; } else { //there is a screen_name //Regex Check for valid chars $valid = !preg_match('/[^a-z0-9_ -]/i',trim($screen_name)); if (!$valid) { echo json_encode(false); exit; } //SQL $results = $this-&gt;EE-&gt;db-&gt;query("SELECT member_id FROM exp_members WHERE screen_name = '$screen_name' and member_id &lt;&gt; '$member_id' limit 1"); if ($results-&gt;num_rows() &gt; 0) { echo json_encode(false); } else { echo json_encode(true); } } </code></pre> <p>?></p> <p>I am not really sure where to go from here. Ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload