Answer the question
In order to leave comments, you need to log in
Evolution CMS - Form Lister. does entering numbers with validation work?
Good day to all!
There was a problem, I wrote a snippet for Thomas, where you can order a call by entering only numbers in the field!
I found the validation class "numeric" for this.
I started testing the form, but it does not send a message to email ...
I.e. works like if I have an empty field, naturally nothing should be sent.
If I enter letters, then the text “Enter the number correctly” pops up, which means it understands that letters are being entered, not numbers, BUT if I enter numbers, then the form simply does not send anything ..
Added ajax + script to the form - but nothing helps
snippet:
<div class="modal_inner modal_request">
[!FormLister?
&formid=`request`
&rules=`{
"phone": {
"numeric" : {
"params": [0,1,2,3,4,5,6,7,8,9],
"message":"Введите номер правильно"
}
}
}`
&formTpl=`@CODE:
<form method="post">
<input type="hidden" name="formid" value="request">
<input type="text" name="phone" placeholder="Введите телефон" class="[+phone.errorClass+][+phone.requiredClass+]" value="[+phone.value+]">
<button type="submit" class="last_button">Жду звонка</button>
<p class="you_can">Или Вы можете позвонить нам прямо с сайта*</p>
<a href="tel:[*phone3*]" class="first_button">Позвонить</a>
<p class="call_us">* Для совершения звонка необходимы микрофон и наушники</p>
</form>`
&successTpl= `@CODE:
<div class="alert alert-success mt-3">
<h3>Thanks!</h3>
<p>your message has been sent.</p>
</div>`
&messagesOuterTpl=`@CODE:<div class="alert alert-danger" role="alert">[+messages+]</div>`
&errorTpl=`@CODE:<span class="help-block">[+message+]</span>`
&errorClass=` has-error`
&requiredClass=` has-warning`
&to=`[email protected]`
&subject=`Новый звонок`
&reportTpl=`@CODE:
<p>Телефон: [+phone.value+]</p>`
!]
</div>
switch($_GET['q']){
case 'request':
echo $modx->runSnippet('FormLister', array(
'formid' => 'request',
'to' => $modx->config['emailsender'],
'subjectTpl' => 'Новый звонок',
'errorClass'=> ' has-error',
'requiredClass'=> ' has-warning',
'rules'=> '{
"phone": {
"numeric" : {
"params": [0,1,2,3,4,5,6,7,8,9],
"message":"Введите номер правильно"
}
}
}',
'messagesTpl' => '@CODE:<div class="form-messages alert alert-danger">[+required+]
[+errors+]</div>',
'errorTpl'=>'@CODE: [+message+]',
'successTpl'=> '@CODE:
<div class="alert alert-success mt-3">
<h3>Cпасибо</h3>
<p>Ваша заявка принята!</p>
</div>',
'formTpl' => '@CODE:
<form method="post">
<input type="hidden" name="formid" value="request">
<input type="text" name="phone" placeholder="Введите телефон" class="[+phone.errorClass+][+phone.requiredClass+]" value="[+phone.value+]">
[+phone.error+]
<button type="submit" class="last_button">Жду звонка</button>
<p class="you_can">Или Вы можете позвонить нам прямо с сайта*</p>
<a href="tel:[*phone3*]" class="first_button">Позвонить</a>
<p class="call_us">* Для совершения звонка необходимы микрофон и наушники</p>
</form>',
'reportTpl'=>'@CODE:
<p>Телефон: [+phone.value+]</p>',
));
die();
break;
}
<script type="text/javascript">
//see plugin evoAjax
$(document).on('submit','.modal_request form',function(ev){
var frm = $('.modal_request form');
$('.last_button').prop( "disabled", true );
//alert( frm.serialize());
$.ajax({
type: 'post',
url: '[(site_url)]request',
data: frm.serialize(),
success: function (data) {
$('.modal_request').empty();
$('.modal_request').html( data );
}
});
ev.preventDefault();
});
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question