×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Making fields Required

Making fields Required 14 years 3 months ago #10390

  • SunPoweredProductions
  • SunPoweredProductions's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
I would like to make certain fields required before the comment can be submitted. Is there a tag I can add to the fields in the template that will do that? Thank you.

2. Sorry if this is a repost. I had a difficult time searching through your forum. It would be nice if I could search the whole "joomlacomments" section, rather than only searching through categories within the "joomlacomments" area, such as "newbe's" or "bugs". Or, if in the advance search I could select more than one category topic, that would do the trick too. Thank you.

Thanks a bunch!
Shelly

Making fields Required 14 years 3 months ago #10391

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey there,
There is no tag that you can add to the template - you will have to edit the js file, but I will need to know which fields you want to edit to tell you what to change.

Making fields Required 14 years 3 months ago #10392

  • SunPoweredProductions
  • SunPoweredProductions's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Hi Daniel,

We'd like to require their email address. I know if you type something into the email address, it checks, but if you type nothing, the submit button works and goes on to the next process.

Thanks,
Shelly

Making fields Required 14 years 3 months ago #10441

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hi, are you using compojoomComment or joomlacomment?

In joomlacomment it doesn't check the validity of the e-mail.

Anyway. For compojoomcomment.
Open components/com_comment/joscomment/js/client.js

On line 396 you will find the JOSC_editPost function. In it you will find this:
	if(typeof(form.temail) != 'undefined') {
		if(form.temail.value != '' && !form.temail.disabled) {
			if (!validate(form.temail.value, form)) {
				return 0;
			}
		}
	}

change it to this:
	if(typeof(form.temail) != 'undefined') {
		if(!form.temail.disabled) {
			if (!validate(form.temail.value, form)) {
				return 0;
			}
		}
	}

that should do the trick.
Daniel

Making fields Required 14 years 2 months ago #10459

  • SunPoweredProductions
  • SunPoweredProductions's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Hi Daniel,

We are using joomlacomment. It is all right that joomlacomment doesn't check for validity, but is there still a way to make it require the user to put something in the email field? (Sorry for the late reply. I've been tied up in another project.)

Thanks,
Shelly

Making fields Required 14 years 2 months ago #10461

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Yep, just put the above code in the JOSC_edit function and you should be ready to go :)

Making fields Required 14 years 2 months ago #10481

  • SunPoweredProductions
  • SunPoweredProductions's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
My code seems to be a little different...
Using jcomments version !JoComment 4.0 beta2
Starts on Line 371 of the client.js file

Very appreciative of your help!
- Shelly
function JOSC_editPost(id, parentid)
{
	var form = document.joomlacommentform;
    if (form.tcomment.value == '') 
    {
        alert(_JOOMLACOMMENT_FORMVALIDATE);
        return 0;
    }
    if  ( document.getElementsByName('tnotify')[0]  && document.getElementsByName('temail')[0] )
    {   if ( form.tnotify.selectedIndex && form.temail.value == '') {
            alert(_JOOMLACOMMENT_FORMVALIDATE_EMAIL);
            return 0;
        }
    }

Making fields Required 14 years 2 months ago #10484

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
change the above code to this:
function JOSC_editPost(id, parentid)
 
{
 
    var form = document.joomlacommentform;
 
    if (form.tcomment.value == '') 
 
    {
 
        alert(_JOOMLACOMMENT_FORMVALIDATE);
 
        return 0;
 
    }
 
 
    if(typeof(form.temail) != 'undefined') {
 
        if(!form.temail.disabled) {
 
            if (!validate(form.temail.value, form)) {
 
                return 0;
 
            }
 
        }
 
    }
   if  ( document.getElementsByName('tnotify')[0]  && document.getElementsByName('temail')[0] )
 
    {   if ( form.tnotify.selectedIndex && form.temail.value == '') {
 
            alert(_JOOMLACOMMENT_FORMVALIDATE_EMAIL);
 
            return 0;
 
        }
 
    }

this should do the trick, but I haven't tested it.

Making fields Required 14 years 2 months ago #10486

  • SunPoweredProductions
  • SunPoweredProductions's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Hi Daniel,

Tested your code. Now it doesn't send at all.
Tried it with and without an email, and it doesn't send at all. It doesn't even process the send.
There is no error popup "Please enter in your email address" that appears in either case.

Waiting the next bit of code replacement. Thank you.

(FYI, we are in no state of panic, as we have the original file uploaded back in. We are very grateful for your assistance.)

- Shelly

Making fields Required 14 years 2 months ago #10487

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hm, interesting. Would you give me an url to your website. I have nowhere beta2 installed and obviously I need to test before giving you some code pieces.

Making fields Required 14 years 2 months ago #10527

  • SunPoweredProductions
  • SunPoweredProductions's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
www.deltaprotectiveservices.com/blog/7-b...ty-risk-for-business

Sorry for the late reply. I got pretty busy this week...

- Shelly

Making fields Required 14 years 2 months ago #10528

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Ah now I understand what is wrong :)
The above code I posted is fine, but you will need to also add the following function to script.js
function validate(email) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var address = email;
	if(reg.test(address) == false) {
		alert('Invalid E-Mail address');
		return false;
	}
	return true;
}

Making fields Required 14 years 2 months ago #10529

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Ah and - the best thing would be to update to the latest version of compojoomComment - cheers! Daniel :)
  • Page:
  • 1
Time to create page: 0.130 seconds