07-18-2013 07:42 AM
Does anyone already do this kind of thing ?
In the registrer form, I would like to have a field where I can input a phone number and when I submit the form, the field is copied to an hidden field with a +41 added before the phone number (if the number begins by 07x).
Solved! Go to Solution.
07-18-2013 05:38 PM
07-18-2013 11:23 PM - edited 07-18-2013 11:48 PM
I have tried your solution and changed it to copy the username to the phone number but it's not working. Value isn't passed from the field to the other. Any idea why ?
Here is my code
07-19-2013 10:15 AM - edited 07-19-2013 10:44 AM
A few suggestions and ideas:
- My earlier instructions were incorrect on one part. Instead of putting "RegisterSubmit()" in the AJAX Submit field, put "RegisterSubmit" without parentheses.
- Your JS code and mine both make use of the "username" field. By default, "username" is not added or enabled on a self-registration. For the code to work, make sure "username" is addded and enabled.
- The code you have is indeed trying to take the "username" and place it into the "visitor_phone" but the code is doing additional logic to check if every single character of the username is in the Unicode range of numeric values:
if((charCode > 47) && (charCode < 58))
The username likely doesn't have numeric values so it skips every letter of the username and tries to write a blank value to the visitor_phone. To test this, enter a username with some numeric values like "abc123". Only "123" will get set to visitor_phone.
- Chrome Developer Tools, Firebug, or similar tools are your friend when debugging JS code. Enable the console in each tool which will give you alerts about any particular errors. For example, you would get an error in the console that JS couldn't reference "username" if it wasn't added to the form (bullet point 2). You can also write your own debug messages in JS with console.log() lines, such as console.log("charCode is: " + charCode);. Just make sure to remove them after you are done troubleshooting for browser compatibilty.
07-22-2013 12:24 AM
Thanks rmehra, now I can copy the username (which is a phone number) to the visitor_phone field. Next step is to add a function that check the username (in fact a phone number) and add a prefix for the numbers begning by 079, 078, 077 or 076.
07-22-2013 04:50 AM
But now, I have another issue. I would like to use phone number in internation format like 004179309XX or 0336367XXXX but it's not working, CP Guest doesn't allowed my to send SMS to this kind of numbers. Anyone has the same problem ?
07-22-2013 10:52 AM
- Can you test manually sending an SMS message from Administrator -> SMS Services -> Send SMS?
- There are options under Administrator -> SMS Services -> SMS Gateways -> Mobile Number Settings that may help. Try playing around with these settings for your international settings and test functionality with a Send SMS tests.
- Enable SMS Gateway debugging from Administrator -> SMS Services -> SMS Gateways -> Mobile Number Settings. Attempt to send a SMS message where it fails and then view Support -> Application Log. Possibly, it isn't CPG failing to send the international number and instead being rejected by your SMS gateway.
- Try disabling validation on your self-registration form for visitor_phone and attempt registering another user.
07-23-2013 12:02 AM
Thanks for your help on the script :)
- So what I mean is if I want to send a SMS to an international number like 004179309XXXX or 00336378XXXX, I can't. Thru the SMS Services it says that it isn't a valid phone number.
- I don't know how to fill in the settings to use international phone numbers (my SMS provider is SMS Global).
- I got an error message "ERROR: 102 SMSGlobalMsgID" so it seems that SMS Global doesn't like the format of the number because it is working with +41 or +33 (but I don't want this format).