Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
in Q2A Core by
edited by
This is really pain. Unexperienced users just hit the exclamation mark too often...

Do I have to do it in jquery or is there an option in q2a I have missed one more time?

Thanks team!

2 Answers

0 votes

Okay, we could use regular expressions in php:

preg_replace('{\?+}', '?', 'Is this thing on??? or what???');

same for exclamation marks.


With javascript you could use:

var text = 'help??? test???';
var regex = /\?+/g;
var replaceWith='?';

0 votes

Final solution using jquery. I added two lines to the "user must give at least 2 tags" part, that I posted here (which is actually not necessary but alerts the user before sending data to the server). And it helps to identify the site (tags are there, so must be a posting).

    // user must give at least 2 tags
    if ($("#tags").length > 0){
        var regForm = $(".qa-form-tall-table").parent();
        regForm.submit(function(e) {
            var tagsN = 0;
            // count tags
            var matches = $("#tags").val().match(/\b/g);
            if(matches) { tagsN = matches.length*0.5; }
            if(tagsN<2) {
                alert("Gib mindestens 2 Stichwoerter zur Frage an!");
                return false;
            // replace multiple question and explanation marks
            var titleText = $('input[name$="title"]').val().replace(/\?+/g,'?').replace(/\!+/g,'!');
            // rewrite title


            return true;


Hope that helps.

where in which file i add this for example  qa-theme-base.php or in other file.
I added it to: qa-content/qa-page.js
(you need a javascript file or a javascript block somewhere).

In qa-page.js do not forget to sourround this by:


... code ...

thanx kai its a nice idea and its working good ....