marklaramee
Forum Replies Created
-
Hi
I did discover another issue: inthe JS, in your docReady function, you assign a keyup “verification_maximum” function to the title field. In this function, you make this assignment unCompteur = jQuery(elemId).val().length. This function works very well for the UI component on the right side.
The issue is…
That unCompteur value is used below on the submit click function: if(unCompteur <= maximum).
The problem is…
If the user comes to the edit page and does not modify the title (say they are just changing the category), when they click submit, they will get the error that the title is too long (at least, in firefox they do). This happens because unCompteur has not been assigned and evaluates as “undefined” and causes the if statement to render as false.
the fix is…
change the if statement in the submit click function as:
if(jQuery(‘#title’).val().length <= maximum)
Apologies if you fixed this already!
Hi Jean-Philippe,
I’m glad that you found some of my code useful. re: the loading icon. Yes, I can see your point. I guess the issue is that if we attach to the click event, we don’t intercept the “return” key. So, people can still submit the form, bypassing out character check.
It’s possible that the loading icon can be overridden via an hook in the PHP. I’ll let you know if I discover anything along those lines.
Thanks for the great plugin BTW. I really like the character counter on the right side. It’s excellent UI.
Hi, another change in the “submitting even though under character count” post,
change
if(unCompteur < maximum)
to
if(unCompteur <= maximum)for people not that familiar with the file structure, the JS file you need to change is here:
/wp-content/plugins/limit-a-post-title-to-x-characters/js/lptx-script.js
Also, the “settings” link in the plugins list was not working. It had the wrong URL. Change link near // Display a Settings link on the main Plugins page:
‘options-general.php?page=limit-a-post-title-to-x-characters/lptx.php’
also, apologies if I am submitting this stuff incorrectly, I’m new to wordpress
I fixed the “submitting even though under character count” Go to the JS file and attach the check to the submit of the form function, not the button press.
change the lines here: jQuery(‘#publish’).mousedown(function()
to this
jQuery(‘#post’).submit(function()
{
if(unCompteur < maximum)
{
return true;
}
else
{
alert(‘You are over the maximum allowed characters for the title!’);
return false;
}
});