Validating customized registration form
I have a customized registration form that I tweaked and works fine. But now I realize that I need to run a validation upon registration to either prohibit or remove spaces in the user name (reason - I build new pages upon registration using the user name, and can't have spaces in the new page names.)
Editme will catch other naming errors so I can just strip spaces with a function like:
function removeSpaces(string) {
var tstring = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
tstring += splitstring[i];
return tstring;
But I haven't had much luck on plugging it in anywhere. I cannot get at the layout for a custom system page and I would rather do this server side than client side. I am about to write a new page and first post the form there and then repost to _Register but that seems akward.
Can anybody suggest a more elegant solution?
Posted at 5:33 AM on August 22, 2008
Maxwell,
The simplest solution would be to have client-side JavaScript strip spaces out of the name automatically. You could do this with an onchange or onblur or even the form's onsubmit event.
Short of that, your options are to 1) build your own registration form that bypasses _Register altogether (all it does is create the new user, after all). Or 2) the option you mentioned - a second form that then posts to _Register, but I agree this is a complicated option.
Cheers,
Matt
Posted at 9:05 AM on August 22, 2008