Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To check the Username/Email Availability do the following:</p> <p>Using the <a href="https://github.com/posabsolute/jQuery-Validation-Engine" rel="nofollow">https://github.com/posabsolute/jQuery-Validation-Engine</a></p> <p>edit the validationsEngines-en.js file for the AJAX calls, one for the email will look like the following:</p> <pre><code> "ajaxEmailAvailable": { "url": "/route_to_send_the_parameters", // you may want to pass extra data on the ajax call "alertTextOk": "* This email is available", "alertText": "* This email is already taken", "alertTextLoad": "* Validating, please wait" }, </code></pre> <p>Make sure you configure your routes.rb file to match the route you want to use, the default action with the call is a GET HTTP Request.</p> <p>Next set up the proper action in your controller to handle the request (I included a helper in the Application Controller so that the input value can be sanitized before queried in the database:</p> <p>CONTROLLER HANDLING THE REQUEST</p> <pre><code> def username_availability scrubb = help.sanitize(params[:fieldValue], :tags =&gt; '') user = User.find_by_email(scrubb) if user.blank? render :json =&gt; ["INPUT_ID", true , ""] else render :json =&gt; ["INPUT_ID", false , "This email is already taken"] end end </code></pre> <p>If you are unsure of the proper INPUT ID, watch the server logs for the parameters passed during the call and do a simple copy-paste. By default the request passes the INPUT ID and INPUT VALUE.</p> <p>To gain access to this helper add the following:</p> <p>APPLICATION CONTROLLER</p> <pre><code> def help Helper.instance end class Helper include Singleton include ActionView::Helpers::TextHelper end </code></pre> <p>Now on the form itself, your input should read as the following:</p> <pre><code>&lt;%= c.text_field :email, "data-validation-engine"=&gt;"validate[required, custom[email], ajax[ajaxEmailAvailable]]" %&gt; </code></pre> <p>As per the proper functionality always place the AJAX call as the last validation.</p> <p>Don't forget to include jquery.js, jquery.validationEngine-en.js, jquery.validationEngine.js and validationEngine.jquery.css in the head of the document [in that order of js] and to call a </p> <pre><code>&lt;script type="text/javascript"&gt;$(function() {$("#FORM_ID").validationEngine();});&lt;/script&gt; </code></pre> <p>If you want to do this for username, just edit the above appropriately.</p>
    singulars
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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