Alpha Video Training
Results 1 to 6 of 6

Thread: New User Registration Validation

  1. #1
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    661

    Default New User Registration Validation

    I have the below code in the click event of a submit button for new user registration. It is suppose to check to see if there are values in the username and password fields before registering the user. This use to work but now with this code in the submit button, when the submit button is clicked nothing happens. Any ideas why this code doesnt run when submit button is clicked?

    var controlsToValidate = ['USERNAME1', 'PASSWORD1', 'PASSWORD2'];
    var flagHasError = false;
    var result = '';

    for(var i = 0; i < controlsToValidate.length; i++) {
    result = {dialog.object}.clientSideValidateField(controlsToValidate[i],1);
    if(typeof result == 'string') flagHasError = true;
    }

    if(!flagHasError) {
    {dialog.object}.runAction('Submit Message Box');
    }

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,667

    Default Re: New User Registration Validation

    This is an error Alpha introduced by changing the nature of .clientSideValidateField()... and the documentation is wrong... because... Alpha doesn't test their work... and... Alpha doesn't test the code they put in the documentation. It's not hard to test this stuff... they simply won't do it... or don't care... it's a mystery.

    Alpha introduced this bug somewhere around build 5447. .clientSideValidateField() used to return either a boolean or a string. Boolean as true if the test passed. String as an error string if the test failed. Now it returns either an empty string if passed... or an an error message string if it fails.

    The documentation code you copied only tests for a typeof string. Since a string is always returned... error or not... it always fails.

    This code should look after stuff a bit better... but test it thoroughly.

    Code:
    for(var i=0; i<controlsToValidate.length;i++){
    	var result = {dialog.Object}.clientSideValidateField(controlsToValidate[i],1);
    	if(result != undefined){
    		if(typeof result != 'boolean'){
    			if(typeof result == 'string'){
    				if(result != "") flagHasError = true;
    			}
    		}
    	}else{
    		flagHasError = true;
    	}
    }
    Last edited by Davidk; 08-16-2019 at 09:53 AM.

  3. #3
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,351

    Default Re: New User Registration Validation

    Sounds like Alpha actually improved it.
    While I would prefer some value instead of an empty string, it's nice to know you only
    need to validate the result itself (result != "").

  4. #4
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,667

    Default Re: New User Registration Validation

    Agreed... and I've changed my post because it isn't a bug... but rather an error Alpha introduced. They didn't tell anyone of the change and existing code no longer worked. Then they updated the doc and it's wrong.

  5. #5
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    661

    Default Re: New User Registration Validation

    This code below is still not working. What is the best way to debug this? I want the Submit Message Box action javascript to fire if the username and two password boxes have a string value and not fire if they are empty.

    var controlsToValidate = ['USERNAME1', 'PASSWORD1', 'PASSWORD2'];
    var flagHasError = false;
    var result = '';

    for(var i=0; i<controlsToValidate.length;i++){
    var result = {dialog.Object}.clientSideValidateField(controlsToValidate[i],1);
    if(result != undefined){
    if(typeof result != 'boolean'){
    if(typeof result == 'string'){
    if(result != ""){
    if(flagHasError = true){
    {dialog.object}.runAction('Submit Message Box');
    }
    }
    }
    }
    }else{
    flagHasError = true;

    }
    }

  6. #6
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,667

    Default Re: New User Registration Validation

    It's not working because it's wrong. The way your code reads... if you encounter an error, then you run your runAction. You need to move that runAction out of the loop because... if your code was correct... and you did not encounter an error for a control... e.g. 1 out of 3 controls passed... then your runAction would run. Your logic and your code is wrong. You need to test flagHasError once the loop is done.

    Code:
    var controlsToValidate = ['USERNAME1', 'PASSWORD1', 'PASSWORD2'];
    var flagHasError = false;
    
    for(var i=0; i<controlsToValidate.length;i++){
    	var result = {dialog.Object}.clientSideValidateField(controlsToValidate[i],1);
    	if(result != undefined){
    		if(typeof result != 'boolean'){
    			if(typeof result == 'string'){
    				if(result != "") flagHasError = true;
    			}
    		}
    	}else{
    		flagHasError = true;
    	}
    }
    
    if(!flagHasError){
    	{dialog.object}.runAction('Submit Message Box');	
    }

Similar Threads

  1. User registration
    By leec2000 in forum Mobile & Browser Applications
    Replies: 10
    Last Post: 07-24-2014, 09:47 PM
  2. Mobile user-managed registration (self-registration)
    By parkjammer in forum Mobile & Browser Applications
    Replies: 0
    Last Post: 12-11-2013, 09:07 PM
  3. User Registration Help
    By russellhaggard in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 07-20-2011, 06:12 PM
  4. User Registration Tutorial
    By parri2bd in forum Application Server Version 10 - Web/Browser Applications
    Replies: 2
    Last Post: 08-13-2010, 04:00 PM
  5. user self registration
    By bob9145 in forum Alpha Five Version 10 - Desktop Applications
    Replies: 12
    Last Post: 06-15-2010, 11:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •