Profile fields restrictions

Started by Buraaq, September 17, 2010, 07:48:11 PM

Previous topic - Next topic

Buraaq

QuoteI had the same question posted elsewhere, but I guess I posted it in the wrong forum; no replies form there. This forum sounds more relevant, so here goes. Copy paste =D
Heya all!

I recently added an additional field to my registration form which was compulsory to be filled in before registration could proceed.

I added this field by enabling "advance profile fields" from Core Features, and then using features and options section to configure this field.

The field's "name" is GR Number, and its an 8 digit long field.

I have built this forum so that students from my institute may only join it, and to ensure that I have used this field. The idea is that every registering student would fill in this field with their unique GR Number (every student is given one when he registers, and this number is unique for every student). I would then confirm this number with my institute's management and if its valid and matches with the student's provided name, I will approve the membership.

Its working fine for now, but I wanted to add an extra level of security by making this field more restrictive. For example, since Gr Numbers are all numerical, I would like this field to disallow any alphabetical input. I know something calling input masking is supposed to do it, but I just cant figure it out 


Furthermore, I would also like this particular field to interact with my database, so that if a given GR Number is already associated with an existing approved/pending approval member, it would notify so to the user trying to get registered while also stopping the entire registration process at this point. I have absolutely no clue how this should be done.


Here is the link to my forum though if anyone would like to get a better picture.


Any help would be greatly appreciated, and thanks a lot in advance!   

Chas Large

Sorry you didn't get a reply elsewhere. I'll try and help.

You can set the Profile Field to be NUMERIC from the Input Mask drop down box and limit the number of numbers entered by setting the Maximum Length in the box above it.

I've just tested these basic settings in a Profile Field with 7 characters and Numeric and if I enter any Alphanumeric characters that are not numbers the input is rejected.

The MASK is like setting a specific set of values that need to be entered. So you can set that a minimum of 6 numbers be entered as well as a maximum. You can also set a mask that governs certain numbers be entered. For example if all your GR numbers begin 22nnnnnn you can set a mask that checks the number entered begins with 22.

Sadly however, my attempts to use the mask details given in the help (?) buttons has met with little success. I know there is a bug in the way that Profile Fields don't show correctly under signatures, perhaps there is a problem with utilising the masks. I'll keep looking and will post back here once I've found the answer.

It would help if you could post how many numbers and what format you need to have as the input.

As for checking the number against already registered numbers, this is not part of the functionality that I am aware of and would, I feel, require some unique coding on the registration page. It would have to do a search of the database where the profile field input is stored and do a comparison against all inputs. Sadly this is beyond my limited programming skills but I'm sure someone would rise to the challenge if asked, perhaps suggest it in a Mod request.

Hope this helps a little.
My Modifications :)  My Forum

Please DO NOT PM me with support requests. Post the problem in the appropriate Support Board so everyone can benefit from the advice given.

Buraaq

Thanks a lot for the response Chas, I was beginning to wonder if this was indeed such a big issue =)

Well my GR numbers are all 8 digits. they begin with 000, but thats just the case mostly. because as more students get registered, these GR numbers will take the form of 00, and then eventually 0...and a time might come where the numbers wont start from 0 at all. Though that time seems way ahead, I dont think I should restrict members to input three Zeros first. In any case, it would sure help to know how this would be done.

And indeed, the field would need to interact with the database and compare the numbers. Thats way beyond me too, but thanks a lot for your input. I will take this to mod request now.

And masking has issues. I tried the mask, but that led to another issue. Whenever a new member registered, their profile didn't show the gr they entered, rather the mask! In this case, all their gr numbers read something like [0-9]+ so I removed the mask altogether.

Hope the bug gets fixed soon though. Once again, thanks for you time  :)

Chas Large

I've been doing a bit of searching and what I missed is the use of the Regex facility to check the mask.

So what you need to do is in the drop down "Input Mask" box, select Regex (Advanced). A new empty box will appear underneath, this is where you place the mask.

This mask for example will require the user to enter the number "1234" into the entry box on the registration page.

~^1234$~

If the user enters anything else, it's rejected, an error message is displayed and registration stalls but if correct it's accepted. and registration completes.

The ^ denotes the start of the input string and the $ the end. The numbers in between are what is to be matched to the user input.

If you knew the first four digits of all numbers for example, you could use

~^1234+~

to check that the first four digits are correct and anything up to the maximum would be accepted. If the first four digits didn't match then the registration would be rejected.
My Modifications :)  My Forum

Please DO NOT PM me with support requests. Post the problem in the appropriate Support Board so everyone can benefit from the advice given.

Buraaq

Thanks a lot for the explanation Chaz! Got it! =)

But before I restrict the input digits, I think I should restrict the field to numerical, so that alphabetical input is disallowed. I selected "numbers" from that drop down list for this purpose, but didn't work out.
So after your post, I decided to select Regex (advanced) and instead of the code you gave me, typed in [0-9]+. This is the code you get when you click on that blue exclamation mark next to Input Mask, and as far as I could understand it, it is supposed to restrict input to numbers only. Didn't work. I could still enter alphabets.  :-\

Chas Large

#5
That code will match numerics but not exclude alphabetics.

This site is quite helpful http://www.regular-expressions.info/reference.html

You'll need to build an expression that allows numerics but precludes alphabetics.

You can use Regex to mask alphanumerics of certain layout but you can't use it in conjunction with the numeric only selection from the mask drop down.

I'll do some testing but not till tomorrow, it's late here now and I'm off to bed. Night.
My Modifications :)  My Forum

Please DO NOT PM me with support requests. Post the problem in the appropriate Support Board so everyone can benefit from the advice given.

Buraaq

Thanks a lot for the link and for all the support! Its later here too, and I should be going as well. Hope to hear from you soon. Take care, and good night  ;)

Hj Ahmad Rasyid Hj Ismail

I think this' solved and I'll mark it as solved for now. If it is not yet resolved, please feel free to open it back.

Buraaq

Its not solved yet =( Plus, my "tab" button misses out this added field for some odd reason too =/

Hj Ahmad Rasyid Hj Ismail

It's reopen back. Care to explain in details how is the tab went missing?

Advertisement: