Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Highlighted
Visitor
Posts: 1
Registered: ‎11-21-2011
My Device: Curve 5.0
My Carrier: Verizon

Form Validation not working for Blackberry Curve 5.0 and Tour 9630?

Blank forms are being sent with no data. Form validation is not being completed. How can I correct this? It works on all other platforms.  I am using form assembly for the forms. I had tried using onSubmit instead of onClick but that did not work. Any help would be very appreciated. Thank you in advance for help.. I AM STUCK...

 

Here is my html form
..........................................................................

 

<form method="post" action="http://www.tfaforms.com/responses/processor" id="id2306366" class="labelsAbove hintsTooltip">
                <div class="form enews">
                    <label><span class="reqMark">*</span>First name:<br /><input type="text" id="tfa_FirstName" name="tfa_FirstName" value="" size="24" class="required"></label>
                    <label><span class="reqMark">*</span>Last name:<br /><input type="text" id="tfa_LastName" name="tfa_LastName" value="" size="24" class="required"></label>
                    <label><span class="reqMark">*</span>Email:<br /><input type="text" id="tfa_EmailAddress" name="tfa_EmailAddress" value="" size="24" class="validate-email required"></label>
                    <label class="phone">Phone:<br /><input type="text" id="tfa_PhoneNumber" name="tfa_PhoneNumber" value="" size="24" class=""></label>

                    <label class="zip"><span class="reqMark">*</span>Zip code:<br /><input type="text" id="tfa_ZipCode" name="tfa_ZipCode" value="" size="24" class="required"></label>
                    <label class="opt-in"><input type="checkbox" value="tfa_4659718305995" class="" id="tfa_4659718305995" name="tfa_4659718305995"> Sign me up for email offers &amp; updates</label>
                </div>
                <div class="actions">
<input type="submit" class="primaryAction" id="submit-" name="tfa_submitAction" value="submit"><input type="hidden" value="224186" name="tfa_dbFormId" id="tfa_dbFormId"><input type="hidden" value="" name="tfa_dbResponseId" id="tfa_dbResponseId"><input type="hidden" value="de6dc6e386a3898cc9b19de8342835d8" name="tfa_dbControl" id="tfa_dbControl"><input type="hidden" value="4" name="tfa_dbVersionId" id="tfa_dbVersionId">
</div>
</form>

 

 

 

Here is the javascirpt

...........................................................................

 

// document.addEventListener('DOMContentLoaded',enableResumeLater,false);
base2.DOM.Element.addEventListener(document, 'DOMContentLoaded',enableResumeLater,false);

function enableResumeLater() {
    var b = document.getElementById('tfa_resumeLater');
    if(b) {
        /**
         * Routine for password confirmation check (localized string can be set in localization-*.js file)
         */
        if(!wFORMS.behaviors.validation.messages.isPasswordConfirmed) {
            wFORMS.behaviors.validation.messages.isPasswordConfirmed = "Your password and confirmation field did not match.";
        }
        wFORMS.behaviors.validation.instance.prototype.isPasswordConfirmed = function(element, password) {
            if(document.getElementById('tfa_confirmPassword')) {
                if(password != document.getElementById('tfa_confirmPassword').value){
                    return false;
                }        
            }
            return true;
        }
        /**
         * Routines for password strength check (localized string can be set in localization-*.js file)
         */
        if(!wFORMS.behaviors.validation.messages.isPasswordStrong) {
            wFORMS.behaviors.validation.messages.isPasswordStrong = "Please choose a more secure password. Passwords must contain 8 or more characters, with at least 1 letter (a to z), 1 number (0 to 9), and 1 symbol (like '%', '$' or '!').";
        }
        wFORMS.behaviors.validation.instance.prototype.isPasswordStrong = function(element, password) {
            var regexp_array = [/^([^\s]{8,})/, /[a-zA-Z]/i, /[0-9]/, /[\"!#$%&'()*+,-.\/:;<=>?@\[\]\\\^_`{|}~]/];
            for(var i =0; i<regexp_array.length; i++){
                if(!password.match(regexp_array[i])){
                    return false;
                }
            }
            return true;            
        }
        if(!wFORMS.behaviors.validation.messages.isPasswordMedium) {
            wFORMS.behaviors.validation.messages.isPasswordMedium = "Please choose a more secure password. Passwords must contain 4 or more characters, with at least 1 letter (a to z) and 1 number (0 to 9).";                                
        }
        wFORMS.behaviors.validation.instance.prototype.isPasswordMedium = function(element, password) {
            var regexp_array = [/^([^\s]{4,})/, /[a-zA-Z]/i, /[0-9]/];
            for(var i =0; i<regexp_array.length; i++){
                if(!password.match(regexp_array[i])){
                    return false;
                }
            }
            return true;            
        }
        if(!wFORMS.behaviors.validation.messages.isPasswordWeak) {
            wFORMS.behaviors.validation.messages.isPasswordWeak   = "Your password cannot be empty.";
        }                    
        wFORMS.behaviors.validation.instance.prototype.isPasswordWeak   = function(element, password) {
            var regexp_array = [/^([^\s]{1,})/];
            for(var i =0; i<regexp_array.length; i++){
                if(!password.match(regexp_array[i])){
                    return false;
                }
            }
            return true;
        }

        // Click handler for the link that opens the Save&Resume fieldset.
        var l = document.getElementById('tfa_saveForLaterLink');
        if(l) {    
            l.onclick = function() {
                
                // Get form element, necessary to retrieve instance.
                f = this;
                while(f && f.tagName!='FORM') {
                    f = f.parentNode;
                }
                
                elem = document.getElementById('tfa_saveForLater');
                if(!elem.checked) {
                    elem.checked = true;
                }
                if(elem.scrollIntoView) {    
                    elem.scrollIntoView();
                } else {
                    location.hash="#tfa_saveForLater";
                }
                
                var b = wFORMS.getBehaviorInstance(f,"switch");
                b.run(null, elem);
            }
        }
        
        // Save button click handler.
        b.onclick = function(e) {
            var f = this.form;
            
            // Save & Resume should not run the full validation. Only resume email and resume password check.
            var bv = wFORMS.getBehaviorInstance(f,"validation");
            if(bv) {                
                // Overwrite the default validation rules, keep a backup.
                var _savedRules = bv.behavior.rules;
                bv.behavior.rules = [];
                
                // Add email validation on save email field.
                bv.behavior.rules.isEmail      = { selector: "#tfa_resumeEmail", check: 'validateEmail' }
                bv.behavior.rules.isRequired = { selector: "#tfa_resumeEmail", check: 'validateRequired' }
                
                // passwordStrength is a server-side configuration setting, set for javascript evaluation in final.xsl.
                if(!wFORMS.behaviors.validation.passwordStrength) {
                    wFORMS.behaviors.validation.passwordStrength = 'low';
                }
                
                // Set validation rules according to desired password strength.
                switch(wFORMS.behaviors.validation.passwordStrength) {
                    case 'high':
                        bv.behavior.rules.isPasswordStrong = { selector: "#tfa_resumePassword", check: 'isPasswordStrong' }
                        break;
                      case 'medium':
                          bv.behavior.rules.isPasswordMedium = { selector: "#tfa_resumePassword", check: 'isPasswordMedium' }
                          break;
                    case 'low':
                    default:
                        bv.behavior.rules.isPasswordWeak = { selector: "#tfa_resumePassword", check: 'isPasswordWeak' }
                }
                // Add validation rule to check for password confirmation match
                bv.behavior.rules.isPasswordConfirmed = { selector: "#tfa_resumePassword", check: 'isPasswordConfirmed' }
                
            }
            // Bypass multi-page unload warning
            var b = wFORMS.getBehaviorInstance(f,"paging");
            if(b) { b.behavior.warnOnUnload=false; }
            
            // Run validation
            if(bv && bv.run(null,f)){
                this.value=" ... ";
                f.submit();
            } else {
                // restore default validation rules.
                if(bv) {
                    bv.behavior.rules = _savedRules;
                }
            }
        };
    }
}

/**
 * Display of validation error. Alert message + scroll into view of the first field in error.
 */
wFORMS.behaviors.validation.onFail = function(bInstance) {
    var m = wFORMS.behaviors.validation.messages.notification;
    var firstErrorId = null;
    var c = 0;
    for (var id in bInstance.elementsInError) {
        c++;
        if(!firstErrorId)
            firstErrorId = id;
    }
    m = m.replace('%%', c);
    
    var elem = document.getElementById(firstErrorId);
    if(elem.scrollIntoView) {    
        elem.scrollIntoView();
    } else {
        location.hash="#"+firstErrorId;
    }
    alert(m);
}