Tuesday, May 02, 2006

Modifying the registration component (com_registration)

Today I decided to jump straight into the the registration component and modify it.

The form-validation if-statement in registration.html.php listed below was quick to modify. Now I have to decide where to define the two things I'm adding:

1. The subscriber validation function: subscriber_exists($id)
2. The error message constant: _REGWARN_SUBSCRIBER

The function does a database lookup so I guess I got to put it in the data later: registration.php, not the presentation layer: registration.html.php , but there are no obvious examples to follow. Going to have look it over and make a reasonable guess.


function submitbutton() {
    var form = document.mosForm;
    var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
    
    // do field validation
    if (subscriber_exists(form.subscriberid.value)) {
        alert( "<?php echo html_entity_decode(_REGWARN_SUBSCRIBER);?>" );
        } else if (form.name.value == "") {
        alert( "<?php echo html_entity_decode(_REGWARN_NAME);?>" );
        } else if (form.username.value == "") {
        alert( "<?php echo html_entity_decode(_REGWARN_UNAME);?>" );
        } else if (r.exec(form.username.value) || form.username.value.length < 3) {
        alert( "<?php printf( html_entity_decode(_VALID_AZ09), html_entity_decode(_PROMPT_UNAME), 2 );?>" );
        } else if (form.email.value == "") {
        alert( "<?php echo html_entity_decode(_REGWARN_MAIL);?>" );
        } else if (form.password.value.length < 6) {
        alert( "<?php echo html_entity_decode(_REGWARN_PASS);?>" );
        } else if (form.password2.value == "") {
        alert( "<?php echo html_entity_decode(_REGWARN_VPASS1);?>" );
        } else if ((form.password.value != "") && (form.password.value != form.password2.value)){
        alert( "<?php echo html_entity_decode(_REGWARN_VPASS2);?>" );
        } else if (r.exec(form.password.value)) {
        alert( "<?php printf( html_entity_decode(_VALID_AZ09), html_entity_decode(_REGISTER_PASS), 6 );?>" );
        } else {
        form.submit();
    }
}

0 Comments:

Post a Comment

<< Home