Validate Alert without block the sending of the form

mahmoodee

Member
Hello ,
I want to validate if the email is unique value,
I want to show this message "the email is already exist" , before send the form and without block the sending of the form .
is there a way to do that ? thank you
 
You can add this in the e-mail element javascript blur event:
JavaScript:
jQuery.ajax({
  url: 'index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=CheckEmail&email=' + this.getValue(),
  method: 'get',
  context: this
}).done(function (myresult) {
  if(myresult != '') {
    alert("This e-mail address already exists!");
  }
});


and this in user_ajax.php:
PHP:
public function CheckEmail()
{
    $mydb = JFactory::getDBO();
    $app = JFactory::getApplication();
    $input = $app->input;

    $myemail = $input->get('email', '');

    $mydb->setQuery("SELECT email_element FROM tablename WHERE email_element = ".$mydb->Quote($myemail));
    $myresult = $mydb->loadResult();
    echo $myresult;
}

Of course change the table and element names in SELECT query to match yours. This exact code is not tested, so you may need to adjust.
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top