By RiseStudent on Wednesday, 11 March 2015
Posted in General Issues
Likes 0
Views 1K
Votes 0
Hi,

I am setting up a site which uses single session for joomla and moodle. I want to validate usernames for easysocial compatible with moodle, moodle doesn't allow spaces in username but easysocial does, which creates error. I want easysocial to accept only alphanumeric values and hyphen, underscore or period (-/_/.).

I have attached moodle allowed characters description and my easysocial regexp settings screenshot, registration form screenshot as its not validating as I think.

Any help or suggestion?
Hello,

Can you try to use this format instead: ^[-_a-zA-Z0-9]*$ and see how it goes.
·
Wednesday, 11 March 2015 23:39
·
0 Likes
·
0 Votes
·
0 Comments
·
Dear NIK FARIS,

It's really helpful. I tried ^[-_a-z0-9]*$ as I don't want upper case either and it works fine, and I want a little more restriction that the username should start from alphanumeric character not a hyphen or underscore, will the regexp value ^[a-z][-_a-z0-9]*$ work for that, as it looks fine to me.

Can you elaborate me this Regexp formatting that how it works or suggest me any tutorial, and what is "Regexp modifier". Also I want to modify error message for regexp to guide the user about valid username e.g. The username may only contain lowercase alphabets, numerals and underscore.

Thanks
·
Thursday, 12 March 2015 15:41
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

Actually I'm not really good at this. What I did was Google any tutorial page so that I can refer.
The modifier is used to modify the search. For example, you want to put i for case-insensitive matching.
You can refer to this for more modifier: http://www.w3schools.com/jsref/jsref_obj_regexp.asp

You can change the message int this file: ../language/en-GB/en-GB.com_easysocial.ini and modify this constant: PLG_FIELDS_JOOMLA_USERNAME_PLEASE_ENTER_VALID_USERNAME. Hope this helps.
·
Thursday, 12 March 2015 16:49
·
0 Likes
·
0 Votes
·
0 Comments
·
It's helpful.

Thank you Nick.
·
Thursday, 12 March 2015 16:58
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

You're welcome.
·
Thursday, 12 March 2015 17:17
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

...will the regexp value ^[a-z][-_a-z0-9]*$ work for that, as it looks fine to me.[/i]


For version 2.1.10, is this still working?
i try a period, like test.test but it's not working.

Thanks for any help.
·
Monday, 30 January 2017 21:17
·
0 Likes
·
0 Votes
·
0 Comments
·
That regular expression still works on 2.1.0 . Since this post is posted since 2015, I would suggest that you start a new thread on the forums instead
·
Monday, 30 January 2017 22:20
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post