Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Client Side immediate validation JavaScript Required. NB!!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Client Side immediate validation JavaScript Required. NB!!!

    Hi, Me Again,

    Client Side immediate validation JavaScript is my issue this time.

    I have the following fields in my grid:
    1. Age [Current Age in years i.e. 15]
    2. ClassMinAge [Min age i.e. 14]
    3. ClassMaxAge [Max age i.e. 17]
    4. RaceClass [ OR1 - Class OR1 was chosen by a Radio Button. Other classes in the same radio button choices are OR2 & OR3]


    Immediate Validation Required when user "clicks" the RaceClass button for either option OR1, OR2 or OR3.
    1. If Age is > than ClassMinAge AND < than ClassMaxAge AND the button for OR1 [class for ages between 14 and 17] is clicked, the result will be fine and correct.
    2. If Age is > than ClassMinAge AND < than ClassMaxAge AND the button for OR2/OR3 is clicked, the result will be incorrect and a message should be displayed "Not correct Age for Class".
    3. If Age is < than ClassMinAge the result will be incorrect and a message should be displayed "To Young for Class".
    4. If Age is > than ClassMaxAge the result will be incorrect and a message should be displayed "To Old for Class".


    I have tested standard example validation script and it does work correctly, however, the above script is way beyond me currently.
    PLSE assist me in getting the correct script.

    #2
    Re: Client Side immediate validation JavaScript Required. NB!!!

    ANYBODY PLSE !!!

    Advice on what videos/documentation I can study would also be appreciated please.

    Comment


      #3
      Re: Client Side immediate validation JavaScript Required. NB!!!

      Cornelius,

      Can you include more information about what you are trying to accomplish? The more information you provide the easier it will be for someone to help. Be as specific as possible. A screen shot of your grid would be nice.

      Comment


        #4
        Re: Client Side immediate validation JavaScript Required. NB!!!

        Hi Dave,

        Thanks for the feedback. I made some changes to my explanations. The entrant is a Junior competing in a senior race event. If a junior enters a senior race event then they are only allowed to enter the HighSchoolClass AND only if they are between the ages of 14 to 17 and they ride a motorcycle with a certain engine size.

        My scenario below is for the radio button validation to verify the above IF and WHEN the junior entrant chooses a NOT ALLOWED class which would be OR1, OR2, OR3. The message should then popup with a warning. Silver Class starting age is 16 which makes it an allowed race for the age group.
        • RaceType � [Choice between Senior Event & Junior Event. This example is a senior event]
        • Age � [Age id days to determine exact age. 1 day makes a difference]
        • RaceNr � [Official Race number allocated to competitor [Quad numbers start with a L]
        • BikeType � [Choice between Motorcycle & Quad. Each has its own classes]
        • EngineCapacity � [Choices of different capacities, The bike chosen by the entrant is �Less than 251cc�]
        • Stroke � [Choice between 2-Stroke & 4-Stroke]
        • SeniorPrimaryClass � [Radio Buttons with the senior motorcycle classes]
        • HighSchoolClassMinAge � [Min Age to enter Highschool class, Including 14]
        • HighSchoolClassMaxAge � [Max Age to enter Highschool class, below 17, not 17]
        • OR3SilverClassMinAge � [Min Age to enter OR3 & Silver Class, including 16]
        • OR1OR2Class � [Min Age to enter OR1 & OR2 class, including 18]


        Scenario description:
        • A competitor with the Age of 14.29 enters a senior race
        • The competitor rides a motorcycle with enigine size �< 251cc 4 stroke�
        • The competitor chooses OR1 as the class he/she wants to compete in [Not Allowed]


        Validation must [on button click for OR1] check if the competitor�s credentials are allowed to enter the OR1 class;
        • Is the race number valid for a motorcycle race [if starting with a �L� then no motorcycle classes can be entered]
        • Is the age valid for OR1 class?
        • Is the Engine capacity allowed in the OR1 class


        Motorcycle classes and engine capacities allowed per class
        OR1 Class
        1. 2 stroke > than 251cc
        2. 4 stroke > than 401cc


        OR2 Class
        1. 202cc 2 stroke to 251cc 2 stroke
        2. 252cc 4 stroke to 401cc 4 stroke


        OR3 Class
        1. < 201cc 2 stroke
        2. < 251cc 4 stroke


        HighSchool Class
        1. < 201cc 2 stroke
        2. < 251cc 4 stroke


        Ages allowed per class
        OR1 - Age>=18
        OR2 - Age>=18
        OR3 & Silverclass - Age>=16
        HighSchool - Age>=14 and <17

        Comment


          #5
          Re: Client Side immediate validation JavaScript Required. NB!!!

          Apologies, The entries below is actually database fields and some descriptions of their respective functionalities.

          •RaceType – [Choice between Senior Event & Junior Event. This example is a senior event]
          •Age – [Age id days to determine exact age. 1 day makes a difference]
          •RaceNr – [Official Race number allocated to competitor [Quad numbers start with a L]
          •BikeType – [Choice between Motorcycle & Quad. Each has its own classes]
          •EngineCapacity – [Choices of different capacities, The bike chosen by the entrant is “Less than 251cc”]
          •Stroke – [Choice between 2-Stroke & 4-Stroke]
          •SeniorPrimaryClass – [Radio Buttons with the senior motorcycle classes]
          •HighSchoolClassMinAge – [Min Age to enter Highschool class, Including 14]
          •HighSchoolClassMaxAge – [Max Age to enter Highschool class, below 17, not 17]
          •OR3SilverClassMinAge – [Min Age to enter OR3 & Silver Class, including 16]
          •OR1OR2Class – [Min Age to enter OR1 & OR2 class, including 18]

          Comment


            #6
            Re: Client Side immediate validation JavaScript Required. NB!!!

            Once again SOOOORRRRYYYYY

            Attached is an image of the actual screenEntry Form.jpg

            Comment


              #7
              Re: Client Side immediate validation JavaScript Required. NB!!!

              In the end I will adapt your code for each button choice to be made. I need to start learning this somewhere.

              Comment


                #8
                Re: Client Side immediate validation JavaScript Required. NB!!!

                This will hopefully give you an idea of what you need to do. Select the OR1OR2Class control in the Controls view and double click on the "Validation Javascript" property. Enter the following code. Be sure to double check the field names and the logic. I may not have understood everything correctly.

                Code:
                var ClassMinAge = 14;
                var ClassMaxAge = 17;
                var Age = $u.s.toNum({dialog.object}.getValue('Age'));
                
                if (OR1OR2Class == 'OR1')
                {
                    if (Age < ClassMinAge)
                    {
                        return 'Too young for Class';
                    }
                    if (Age > ClassMaxAge)
                    {
                        return 'Too old for Class';
                    }
                }
                
                if (OR1OR2Class == 'OR2' || OR1OR2Class == 'OR3')
                {
                    if (Age >= ClassMinAge && Age <= ClassMaxAge)
                    {
                        return 'Not correct Age for Class';
                    }	
                }
                
                return false;
                Do you have a Submit button on your form to update the data to your database? You may also need to add validation logic to the server-side event dialogValidate if it allows you to submit when there are validation errors. You have to use Xbasic however, which is different than Javascript. There is an example in the event showing you how to validate fields.

                Comment


                  #9
                  Re: Client Side immediate validation JavaScript Required. NB!!!

                  Hi Dave

                  I have adapted the code to represent the correct fields, but it still don't work. I see on the examples that they state to use "Data" to refer to the value in the control to be validated.
                  I also call the data from the other fields as the ages might change in future, which means I will have to "code" change them to work then.

                  var ClassHighSchoolMinAge = $u.s.toNum({dialog.object}.getValue('ClassHighSchoolMinAge'));
                  var ClassHighSchoolMaxAge = $u.s.toNum({dialog.object}.getValue('ClassHighSchoolMaxAge'));
                  var Age = $u.s.toNum({dialog.object}.getValue('Age'));

                  if (PrimaryClass == 'OR1')
                  {
                  if (Age < ClassHighSchoolMinAge)
                  {
                  return 'Too young for Class';
                  }
                  if (Age > ClassHighSchoolMaxAge)
                  {
                  return 'Too old for Class';
                  }
                  }
                  if (PrimaryClass == 'OR2' || PrimaryClass == 'OR3')
                  {
                  if (Age >= ClassHighSchoolMinAge && Age <= ClassHighSchoolMaxAge)
                  {
                  return 'Not correct Age for Class';
                  } else {
                  return false;
                  }

                  Comment


                    #10
                    Re: Client Side immediate validation JavaScript Required. NB!!!

                    You don't have to use "data" to refer to the field. I didn't use it in this example because you are using more than 1 data field in your validation logic. I also thought that you may want to add this validation logic to the Age control as well. You could copy and paste the same code for the "Age" JavaScript validation property. If you used "data", it would not work.

                    You can't use "else", otherwise the callback may not return "false" when there are no validation errors. I'm not sure what will happen if it does not return "false":

                    Code:
                    if (PrimaryClass == 'OR1') 
                    {
                         if (Age < ClassHighSchoolMinAge)
                         {
                              return 'Too young for Class';
                         }
                         if (Age > ClassHighSchoolMaxAge)
                         {
                              return 'Too old for Class';
                         }
                    }
                    
                    if (PrimaryClass == 'OR2' || PrimaryClass == 'OR3')
                    {
                         if (Age >= ClassHighSchoolMinAge && Age <= ClassHighSchoolMaxAge)
                         {
                              return 'Not correct Age for Class';
                         }
                    }
                    
                    return false;

                    Comment


                      #11
                      Re: Client Side immediate validation JavaScript Required. NB!!!

                      Hi Dave,

                      Thanks a lot, I seem to have the basic validation scripts working as it should [See below].

                      What i'm still battling with is the following;
                      • Do a validation whereby i check if a race number starts specifically with a "L". If yes then pop a message stating that this is not a valid motorcycle race number.


                      The code below works fine as you suggested, however when I validate more than 1 field, it does not run.
                      Example:

                      The code below works fine on the min & max age, but I still need to validate against the engine capacity as well.
                      Where would I put this statement. [If(Enginecapacity <> 'Bigger than 251cc')

                      /* HighSchool Class validation */
                      if(SPrimClass == 'HighSchool')
                      {
                      if(AgeN < HSMinAgeN || AgeN > HSMaxAgeN)
                      {
                      return 'You must be older than 14 and younger than 16 to enter HighSchool class';
                      }
                      }

                      Comment


                        #12
                        Re: Client Side immediate validation JavaScript Required. NB!!!

                        Sorry Dave,

                        Below the code
                        /* OR1 & OR2 Age & Engin Class validation */
                        if(SPrimClass == 'OR1' || SPrimClass == 'OR2')
                        {
                        if(AgeN < Or12MinAgeN)
                        {
                        return 'You must be older than 18 for Class OR1 & OR2';
                        }
                        }

                        if(SPrimClass == 'OR1')
                        {
                        if(EngineSize <> 'Bigger Than 401cc')
                        {
                        return 'Engin Size';
                        }
                        }

                        Comment


                          #13
                          Re: Client Side immediate validation JavaScript Required. NB!!!

                          When you say it doesn't work, what does it do exactly? Do you get an error message? You can also insert alerts into the validation code to make sure the values of the fields are what you think they are? Or you might also display some text so you know the code executed to that point. For example:

                          Code:
                          /* OR1 & OR2 Age & Engin Class validation */
                          if (SPrimClass == 'OR1' || SPrimClass == 'OR2')
                          {
                               if(AgeN < Or12MinAgeN)
                               {
                                    return 'You must be older than 18 for Class OR1 & OR2';
                               }
                          }
                          
                          alert(EngineSize );    // This will display the value of the EngineSize field in an alert dialog. You can add as many alert statements as you want.
                                                 // If you have more than one alert, you may want to display some static data so you know what you are look at.
                                                 // For example, alert('Engine size = ' + EngineSize);                              
                          
                          if (SPrimClass == 'OR1')
                          {
                               if (EngineSize != 'Bigger Than 401cc')     // <-- Use "!=" and not "<>"
                               {
                                    return 'Invalid engine size.';
                               }
                          }
                          
                          alert('Made it here.');  // Display some arbitrary text so I know the code executed to this point.
                          
                          return false;

                          Comment


                            #14
                            Re: Client Side immediate validation JavaScript Required. NB!!!

                            Hi Dave,

                            Nope, no errors at all. It just "tries" to load the page, but never completes. I think it cannot "understand" the code.

                            Let me try the alerts above. I'll let you know.

                            The != means "is not" ??

                            Comment


                              #15
                              Re: Client Side immediate validation JavaScript Required. NB!!!

                              It won't even render your UX component? If not, does it render if you remove all of the JavaScript validation code?

                              You said earlier that you got it to partially work, but it wasn't doing all of the validation checking that you wanted. Did it render the component and execute the first part of the validation code correctly? If so, did it stop working when you added the additional code to check the engine size? Let me know exactly what is working and what is not.

                              Also, if you want to check the race number to see if the first character is equal to "L", you would enter the following:

                              Code:
                              if (RaceNr.length > 0 && RaceNr[0] == 'L')
                              {
                                   return 'Invalid race number';
                              }
                              You need to make sure the Race Number is greater than 0, otherwise you will get an error if it is left blank.

                              Comment

                              Working...
                              X