CPG does allow you to run custom JavaScript when the Submit button is hit. To set up this workflow, edit the self-registration register form and edit the submit field. Under the Advanced Properties, there is a field for AJAX Submit. This is where you can enter a JavaScript function name, such as "RegisterSubmit()". Next, edit the self-registration registration footer. This is where you can write your custom RegisterSubmit function.
Below is an example JavaScript function that reverses the phone number which should give you a decent prototype to get started on your custom function. In this example, make sure visitor_phone is enabled on the register page form.
<script type="text/JavaScript"><!--{literal}
function RegisterSubmit(form_name) {
var frm = document.forms[form_name];
var error = '';
// Checking here...
if (error != '') {
alert(error);
Nwa_EnableFormButtons(form_name);
return false;
}
// Reverse the phone number and put it as the username.
if (frm.visitor_phone.value != '') {
var name = '';
var phone = frm.visitor_phone.value.split('');
for (var i = 0; i < phone.length; i++) {
var charCode = phone[i].charCodeAt(0);
if((charCode > 47) && (charCode < 58)) {
name = phone[i] + name;
}
}
frm.username.value = name;
}
return true; // Proceed to regular
}
//-->
{/literal}</script>