Add custom confirm message to standard joomla 3.0 admin toolbar button.
I can get alert messages on delete when I don't selected any check boxes on detailed list.
I can get same on any button by set last parameter true in
JToolBarHelper::custom('userdetails.sendMail', 'mail.png', 'mail_f2.png', 'Send Mail', false);
I want to add a confirm message on the click event of this Button?
On view file (tpl/view file name).
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'userdetails.sendMail')
{
if (confirm(Joomla.JText._('Do you really want to send mails to selected users?'))) {
Joomla.submitform(task);
} else {
return false;
}
}
}
</script>
Just as an addition to Suman Singh's answer, you may want to include the script in the document header, and also be able to translate the confirmation text. So, in your layout file, you can write:
$document = JFactory::getDocument();
$document->addScriptDeclaration('
Joomla.submitbutton = function(task) {
if (task == "userdetails.sendMail") {
if (confirm(Joomla.JText._("COM_YOURCOMPONENT_USERDETAILS_SENDMAIL_CONFIRMATION_TEXT"))) {
Joomla.submitform(task);
} else {
return false;
}
}
}
');
JText::script('COM_YOURCOMPONENT_USERDETAILS_SENDMAIL_CONFIRMATION_TEXT');
And of course in the language/en-GB/en-GB.com_yourcomponent.ini file:
COM_YOURCOMPONENT_USERDETAILS_SENDMAIL_CONFIRMATION_TEXT="Are you sure you want to send mails to the selected users?"
Related
So I added rule on button in record subgrid, so when condition is met it will return false and supposedly hide the button. The script is working but instead of hiding the button, it make the button disabled (can't be clicked). Am I missing something? Never used xrm ribbon workbench before.
Here is my script below:
function validatebuttondelete()
{
var entityName = Xrm.Page.data.entity.getEntityName();
if(entityName == "msdyn_workorder")
{
if(Xrm.Page.ui.getFormType() != 1)
{
var received = Xrm.Page.getAttribute("mjt_received").getValue()
var receivedSp = Xrm.Page.getAttribute("mjt_received_sp").getValue()
var stageName = Xrm.Page.data.process.getActiveStage().getName();
if(stageName == "Branch")
{
if(received == 0)
{
return false;
}
else
{
return true;
}
}
if(stageName == "Service Point")
{
if(receivedSp == 0)
{
return false;
}
else
{
return true;
}
}
}
}
}
You can read about Enable rule & Display rule here.
To hide the delete button (trash can/dustbin icon) in subgrid completely - you can simply right click & “Hide” it. Read more
But your requirement is little more complex. Has to be hidden based on some rule. Atleast for you it was disabled. Many people tried that & finally ended up in simple alert message as the button didn’t cooperate.
Reference
the (missing: Enable rule) did not hide the delete button, but allowed us to prevent the Delete action for the disabled records. We went ahead and unhid the Delete button, and then selected the Customize Command option. This populated the Mscrm.DeleteSelectedRecord command under the Command in Ribbon Workbench. We added another Enable rule called RestrictDeleteFromSubgrid
How to have a custom message validity in Google recaptcha?
If the user didn't or forgot to checked the Google Recaptcha checkbox before clicked the submit button. There's a popup message will displayed, the the user need to check first the checkbox.
I have JS that will validate the input text box and it is working. But I don't know how to implement it in Google Recaptcha
JS:
function InvalidMsg(textbox){
if(textbox.validity.patternMismatch){
textbox.setCustomValidity('Please enter your name here');
} else if(textbox.validity.valueMissing){
textbox.setCustomValidity('This field is required');
} else {
textbox.setCustomValidity('');
}
return true;
}
You have to use the reCaptcha verify response call back. Something like this: https://www.google.com/recaptcha/api.js?onload=reCaptchaCallback&render=explicit'>
You will also want to attach your error message to the reCaptcha container you are using.
var RC2KEY = 'sitekey',
doSubmit = false;
function reCaptchaVerify(response) {
if (response === document.querySelector('.g-recaptcha-response').value) {
doSubmit = true;
}
}
function reCaptchaExpired () {
/* do something when it expires */
}
function reCaptchaCallback () {
grecaptcha.render('id', {
'sitekey': RC2KEY,
'callback': reCaptchaVerify,
'expired-callback': reCaptchaExpired
});
}
document.forms['form-name'].addEventListener('submit',function(e){
if (doSubmit) {
/* submit form or do something else */
}
else {
/**
* Show your error message here.
* InvalidMsg function may not work.
* recaptcha does not have properties you are checking for.
*/
}
})
I have a problem with this script. When I press 'yes' it deletes the user which is fine. My problem is that it still deletes the user when I click cancel. Any ideas?
<script>
function myFunction() {
var x;
if (confirm("Are You Want To Delete This User ?") == true) {
x = "delete.php";
} else {
x = "memberlist.php";
}
document.getElementById("demo").innerHTML = x;
}
</script>
The mentioned JavaScript works fine. It may be that there is some issue in your delete.php or memberlist.php code. For a solution as per your expectations, please provide the code for delete.php and memberlist.php.
I assume your element is a link with "delete.php" as href - that is a VERY bad idea unless you want google spider to delete your database
You need to return false on a link's click event if you do not want it to execute - but see 1
I suggest
window.onload=function() {
document.getElementById("deleteLink").onclick=function() {
if (confirm("Do you really want to delete?") {
location="delete.php?user="+this.getAttribute("data-user");
}
}
return false // cancel link
}
using
Delete
Generic for more than one user:
window.onload=function() {
var deleteLinks = document.querySelectorAll(".deleteLink");
for (var i=0;i<deleteLinks.length;i++) {
deleteLinks[i].onclick=function() {
var user = this.getAttribute("data-user");
if (confirm("Do you really want to delete "+user+"?") {
location="delete.php?user="+user;
}
}
}
return false // cancel link
}
using
Delete Frank
Delete Bob
you can add confirm in your url
Edit : sory about spelling mistake i just want to show an alternative way i am texting on phone
<a onclick="return confirm('you are going to delet it are you sure bobo ?')" href="#your delet url">
Error is coming when ever I click on the button
Microsoft JScript runtime error: Sys.ParameterCountException: Parameter count mismatch.
Function.emptyFunction = Function.emptyMethod = function Function$emptyMethod() {
/// <summary locid="M:J#Function.emptyMethod" />
if (arguments.length !== 0) throw Error.parameterCount();
}//Error is occuring here.
Yes, I am using JavaScript confirm message in this page which is included in a master page, update panel and ScriptManager as well on the client click of the button, and after clicking this button error is coming below is my code
function Confirm() {
if(document.getElementById('<%= btnSave.ClientID %>').value=="UPDATE")
{
if(document.getElementById('<%= userStatus.ClientID %>').value=="INACTIVE")
{
if (confirm("do you want to make the user INACTIVE? \n By making the user INACTIVE means its all assigned role will be revoked"))
{
document.getElementById("confirm_value").value = "Yes";
}
else
{
document.getElementById("confirm_value").value = "No";
}
}
else
{
document.getElementById("confirm_value").value = "active";
}
}
}//endFun
Actually I am using ScriptManager in the master page and Update Panel so to get rid of this error I set “ScriptMode="Release" “ of ScriptManeger and it works now no that error is not coming any more.This is the link which helped me out
http://msdn.microsoft.com/en-us/library/bb344940%28v=vs.110%29.aspx
Language: Javascript (PHP page)
I have 2 buttons on a page:
-- One is an upload image button (#upload),
-- & another is a "save / submit form" button (.multi-accordion-submit).
What the .js below does is it disables the submit button (.multi-accordion-submit) while files are being uploaded while user uses the other button (#upload) & text inside #upload says "Uploading...".
After an upload & text goes back to "Upload More" for #upload, the .multi-accordion-submit button's disabled attribute should now be removed.
But the problem is, it remains disabled and unclickable, rendering the submit button (.multi-accordion-submit) useless.
I don't know how to fix it, the code below looks fine & should work.
Any guidance and assistance would be greatly appreciated! Thanks for your time.
$(function () {
var btnUpload = $('#upload');
var status = $('#status');
var url = $('#upload_path').val();
new AjaxUpload(btnUpload, {
action: url,
//Name of the file input box
name: 'image',
onSubmit: function (file, ext) {
$('#upload-error').hide();
if (!(ext && /^(pdf|ai|psd|bmp|cdr|clk|gif|jpg|jpeg|ppt|pub|doc|docx|pcx|pic|pict|pct|png|ps|tif|tiff|emf|wmf|indd)$/.test(ext))) {
// check for valid file extension
$('#upload-error').show();
return false;
}
btnUpload.text('Uploading...');
$('.multi-accordion-submit').attr('disabled', true);
},
onComplete: function (file, response) {
if ($('.file-elements').length > 0) {
if ($('.file-elements:visible').length == 0) {
window.location.href = document.location.href;
} else {
btnUpload.text('Upload More');
$('.multi-accordion-submit').attr('disabled', false);
}
} else {
btnUpload.text('Upload More');
$('.multi-accordion-submit').attr('disabled', false);
}
//Add uploaded file to list
if (response === "success") {
$('<li></li>').appendTo('#files').html(file).addClass('upload-files');
} else {
$('<li></li>').appendTo('#files').text(file).addClass('upload-files');
}
}
});
});
//try to use
$('.multi-accordion-submit').attr('disabled','disabled');
//and
$('.multi-accordion-submit').removeAttr('disabled');
Attribute disabled is either exists or not (it`s value doesn't taken into account)
To remove disabled state from element you need to remove disabled attribute not just change it's value.
$('.multi-accordion-submit').removeAttr('disabled');
Notes:
Actually it may be confusing with jQuery because in 1.6+ prop and removeProp methods was introduced for work with native properties, but to remove disabled state you need to use prop and not removeProp (once removed native properties cannot be added again)
$('.multi-accordion-submit').prop('disabled', false);