validate required radio button

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
User avatar
wsiconcrete
Posts: 18
Joined: 2015-04-27 16:39
Location: SC, USA

validate required radio button

Post by wsiconcrete » 2015-05-01 02:49

have a required field that uses radio buttons with no default. If no radio button is selected I expected a modal dialog to inform the user they needed to select an option and stop form submission. Instead the form submits to a page with a warning that the field cannot be blank and a "Back" button. Of course the back button doesn't work either because it is asking if you want to resubmit the form.

Looking at the common_js.php file I see the validateData function there, but it is only looking to see if the field is blank, not looking for a "checked" button. I can get so far with javascript but not sure about inserting the right code in the common_js file as it will be overwritten with future changes.

Should the validateData function generated by AppGini be different if the field type is "radio"? Or do I have to create a custom validation in the hooks folder if I want to use radio buttons for required fields?

Thanks!

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Re: validate required radio button

Post by shasta59 » 2015-05-03 14:16

It depends on what your expectations for the validate function are. It is only checking for empty/non empty states. It is easier to just write your own code to make it work the way you wish. You could write code having it check for certain data, status etc. and then display a custom message. For one client I wrote a routine which allows the admin to put in acceptable values which can be input into a field and then it checks for those values. If the input is not in the acceptable range it then gives them the choice of keeping the value or trying again. (There are reasons, in this case, not to spoon feed the end user with the acceptable values).

AppGini is a framework giving you the basic setup. It gives the basic building blocks and allows you to write code to make it work the way you need it to work.

I write a lot of add on code to make things work the way I want. The biggest benefit is that I get an app up on the web in hours, it works and then I can refine it as I go along.

If the back button is not working there is some other reason for that happening. It should work and take you back.

You also did not state what version of AppGini you are using. This makes it harder to offer assistance because things change over time. Code that worked in an older version will not work in a newer version at times.

Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

User avatar
wsiconcrete
Posts: 18
Joined: 2015-04-27 16:39
Location: SC, USA

Re: validate required radio button

Post by wsiconcrete » 2015-05-03 14:47

Thanks for the reply. I bought AppGiini for the reasons you mentioned, it gives me a foundation to build on and I am still learning all of it's capabilities and more about PHP and JS as I go. I am using the latest release available (5.31)

Not sure if validation was the right term here, but I did expect that when I marked a field as required in AppGini the form would not submit if there was no value passed for that field. I am not concerned with what the value is and shouldn't need to parse/check the input since it is a radio button and thus coded into the form and the input values would always be from the same list of options. What I wanted was for the form to prevent submission if a radio button was not checked.

I haven't had time to get back to this and add the custom code but guess that is the route I will need to go to get this functionality. Thanks again for your input!

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Re: validate required radio button

Post by shasta59 » 2015-05-04 01:33

You can get AppGini to do that but it will take custom code. Just reroute the call for the checking if checked/selected etc or not to some new code to put up a message saying you have to fill in the value and have it stay on the same page. You would also prevent the form submission from happening.

The mystery here is why you cannot go back. I have tested and it goes back to the form without asking for a re-submission of the data. Something else is at play in some code somewhere.

You also do not mention what version you are using. This is important. I put it in the first line of posts when I am posting code so that everyone knows it works for that version.

Ex: I am using version 5.31

Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

Diogenes
Posts: 16
Joined: 2015-05-07 14:03

Re: validate required radio button

Post by Diogenes » 2015-05-07 14:37

I am extremely surprised, shocked, actually, as a new user to learn that the basic default understandings in VALIDATE that have been in use for so many years in javascript are not installed in Appgini. In fact, to me, that is the FIRST mystery, not that you cannot go back and edit the submission.
In fact the submission ought to return with the missing field highlighted and the warning to fill it out or risk not being able to submit the form in the first place.

Even Dreamweaver back the in the early 2000's knew that Validate in a form had a couple of basic meanings and applications.

The first one was what KIND of data is being passed, does it match the data field format.

Another basic expectation from developers was that JavaScript would Prevent the Form submission if certain fields indicated by the javascript were not filled out at all, blank, or did not contain a certain number of numbers or characters.

And every program I have worked with in the past 15 years offers these as the most basic validations necessary.

It is hard to believe that Validation in this latest version of AppGini requires CUSTOM code to simply stop the form submission until the REQUIRED field is filled out. The whole point of REQUIRED is ignored if the form is saved regardless.

AppGini ought to have this as a standard jquery scriplet to be applied in the settings when it asks if a field is Required and What specifically is to be Validated. And keeping the form on the page with now a highlighted field and warning should be the default action.

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Re: validate required radio button

Post by shasta59 » 2015-05-12 02:04

There are programs out there, for many more dollars which will give you all this and much much more. But they are also much much more money. AppGini, as I see it, is targeting those who want the basic framework setup done and then they can add in their own code where needed. It is a great time saver and has been very useful.

Perhaps your expectations would be better met with some of the $400.00 to $600.00 programs which are more inclusive but do not have the ability to get you up and running with a basic framework as fast.

Many users, myself included, need a program to allow rapid (less than an hour) setting up of an application online to accomplish a specific task. Then I also wanted to refine it on my own to add my own features. I have added many many features and now most options are controlled in the admin area due to code I wrote for myself. I have even customized the ability for users to select colour schemes and more to suit their tastes and it saves those settings.

This is what I, and others looked for, the ability to customize. Perhaps this is not the program for you. The price point and flexibility is its strength. It is not a one stop shop and customization is one of the nice features of AppGini. It has saved me hundreds and hundreds of hours of coding time.

It is designed more so for the coder, in my opinion, rather than an end user who has minimal coding skills.

I am sorry to hear it does not work as you wish but that is the joy of the price point. You can make it work as you wish with a little work. Or spend a whole bunch more and get a program which has everything you wish. It all depends on what you want. Since there is a free demo you are able to try it out and make sure it fills your needs before you buy. I have to guess you did that but this instance/issue did not come up in your testing using the free demo.

Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

Diogenes
Posts: 16
Joined: 2015-05-07 14:03

Re: validate required radio button

Post by Diogenes » 2015-05-26 14:21

Shasta59, I appreciate your reply and all of the work you do to help people out.

I have worked with those $400 to $500 dollar programs.

For that reason I know, looking at the code, adapting things, modifying themes, functions, etc, that the "lack" I commented on does not require a fleet of programmers to implement nor is it an exclusive feature that can only be included in "more expensive" programs, nor should the Default function simply ignore the meaning of REQUIRE.

REQUIRE in the case of ANY field should STOP the submission of the form, period.

This is not supposed to be an extra-fancy Custom Coding add-on.

REQUIRE means REQUIRED value, period.
And the rudimentary test should change its conditions by Default, such as in the case of RADIO buttons, to SUBMIT, the whole point of defining REQUIRED.

Across all Common field types in a form, (and Radio Buttons are no mysterious type) , REQUIRED's meaning should apply that the SUBMIT Button, triggering a Save and Update or Insert or Replace action can NOT happen until all the Required form types fulfill basic checks.

Something like This simple test ought to be the DEFAULT function in AppGini for the Radio Button type applied to each radio button when created and marked REQUIRED --

Code: Select all

   <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?>  value="female">Female
   <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?>  value="male">Male
   <span class="error">* <?php echo $genderErr;?></span>
And then the javascript test ought to be looking for these conditions True before the Submit button will work.

So simple a step that AppGini should be applying this or a similar test when a Radio Button type is marked Required.

I will have to modify the Case conditions myself in AppGini but this, I am sure, should be Default by now.

I just downloaded AppGini 5.40 and maybe I will be pleasantly surprised.

This little surprise of mine does not take away my great joy that App-Gini meets most of my needs and makes pages that are much simpler to update, modify, and keep resident from version to version than the More Expensive programs I still work with!

Post Reply