<script>
$('#submitButton').click(function(){
// $('#loading').show();
$.prompt('We are uploading and processing your files, please wait and do not refresh this page……');
// and when finish, call or reload your page: $('#loading').hide();
});
</script>
So basically, when the user clicks on the submit button.
I will prompt them to wait and do not refresh the page.
However, I found that this prompt will occur when the user clicks on submit button even there are still errors in the form(like captcha is not correct).
I want it shows up only the form is validated and the submit button is clicked…
It seems you do Ajax validation, right? So this may help you (put it in the relevant view, or in layouts/main.php if it’s applicable to the whole webapp ):
So do I need to write a class called loading? It seems that the indicator will show up whenever I click submit or not…I don’t quite understand it…Do I need to delete my own codes above?
'afterValidate'=>'js:function(form, data, hasError) {
$.prompt("We are uploading and processing your files, please wait and do not refresh this page……")
}'
),
)); ?>
But the prompt will not show up regardless there are errors or not…
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'some-form',
'enableClientValidation'=>false,
'enableAjaxValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
'validateOnChange'=>false,
'beforeValidate'=>"js:function(form) {
alert('Going to validate. Please click Ok and wait few moments.')
return true;
}",
'afterValidate'=>"js:function(form, data, hasError) {
if(hasError) {
alert('We have detected some input errors and has not saved your data. Please click Ok to correct them.');
return false;
}
else {
if(confirm('We have validated your input and we are ready to save your data. Please click Ok to save or Cancel to return to input.'))
return true;
else
return false;
}
}",
)
)); ?>
PS I’ve just written the messages because the webapp wasn’t in English I hope you get the idea
If I use your code… it always gives me "validation code is not correct…"
If I delete before validation in your code …then no alert will show up at all…
Is there any chance I can just keep the after validation…?
I tried several ways but failed…
And it’s weird…even if I open the ajax validation, The file input will not be ajax validation because if I leave it empty, it will refresh the page and tell me not allow empty…not tell me via ajax way.