This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Changing Name Field Rules
#1

All,
First, I got this comment system to work! A huge achievement for me actually. We run 2Hands.org and our commenting system js-kit went kaput as in they no longer host comments. I needed a fully customizable solution and found commentics. I am so happy.
We require users to register with a 6 digit posting number. This posting number needs to be placed in the name field, which I have changed to 2Hands ID. I get an error saying the name field needs to contain letter etc. How can I disable this so it accepts just the 6 numbers without an error?

Any help is HUGELY appreciated.

I have the form up at http://www.2hands.org/comment.php
Reply
#2

Hi,

Do you want no validation or validation for 6 numbers? I'll post both solutions.

1. No validation

Open /comments/includes/functions/processor.php

At line 408, there is this:

PHP Code:
<?php 
function cmtx_validate_name ($name) { //checks whether name was valid

if (cmtx_is_encoding_iso($name)) { //if encoding is ISO-8859-1
if (!preg_match('/^[a-z0-9&\-\'. ]+$/i', $name) || !preg_match("/^[a-z]+/i", $name)) { //if the submitted name does not validate
cmtx_error(CMTX_ERROR_MESSAGE_INVALID_NAME); //reject user for entering invalid name
}
}

//lower/uppercase letters, numbers, ampersand, hyphen, apostrophe, period, space

} //end of validate-name function

Replace with this:

PHP Code:
<?php 
function cmtx_validate_name ($name) { //checks whether name was valid
} //end of validate-name function

2. Validate 6 numbers

Replace it with this:

PHP Code:
<?php 
function cmtx_validate_name ($name) { //checks whether name was valid

if (cmtx_is_encoding_iso($name)) { //if encoding is ISO-8859-1
if (!preg_match('/\d{5}/', $name)) { //if the submitted name does not validate
cmtx_error(CMTX_ERROR_MESSAGE_INVALID_NAME); //reject user for entering invalid name
}
}

}
//end of validate-name function

You will then want to change the error message. That's in /comments/includes/language/english/processor.php, line 49:

PHP Code:
<?php 
define
('CMTX_ERROR_MESSAGE_INVALID_NAME', 'The name must contain letters and optionally - & . 0-9 \'');

Replace with:

PHP Code:
<?php 
define
('CMTX_ERROR_MESSAGE_INVALID_NAME', 'The 2Hands ID must be 6 numbers');

Have you completed the interview?
Reply
#3

Thank you SO MUCH! I am humbled by your quick response and solution! This is going to be a lifesaver for our website and we all thank you Steven!

The 2Hands.org Team
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Emprador
27-May-2016, 09:53 PM
Last Post by Randy
23-Sep-2014, 07:14 PM
Last Post by Steven
10-Oct-2013, 09:51 PM
Last Post by Steven
15-Oct-2011, 05:53 PM
Last Post by aivarlipp
28-Sep-2010, 05:08 PM
Last Post by james
28-Jul-2010, 05:01 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)