This topic is locked
[SOLVED]

 Working with required fields located in tabs/sections

9/1/2019 8:32:54 AM
PHPRunner General questions
woodey2002 author

Hi Guys,
Phprunner gives us many great ways to work with required fields from the built-in required field option to the IsRequired option in the Javascript API.
It really is amazing what we can do with the software.
I was wondering how our community handle this validation scenario regarding required fields that are located in tabs or sections.
I have a add page, on the add page there are 5 tabs, on the 3rd tab I have two fields that are required.
The users moves along the tabs but they forget to add any data to the required fields on tab 3. (Even after highlighting the required fields via Javascript)
The user is now on the final tab, they press the save button, to the user nothing happens, the record will not save because the user never added data to the required fields on tab 3, without a message telling them this the user would have to manually click back to the 3rd tab to see the "red required field warning" that appears on the required field after they tried to save the record without adding the required data.
Therefore I am somewhat reluctant to add required fields to tabs or sections.
I was wondering how anyone else out there handles this scenario. Is there a way to using tabs/sections...
or
I would love to hear your thoughts, workarounds or solutions on this.
Many thanks,

J

mbintex 9/5/2019

Personally I would never "hide" a required field in the 2nd, 3rd etc. tab but show right upfront, just my 2 cents.

lefty 9/5/2019



Hi Guys,
Phprunner gives us many great ways to work with required fields from the built-in required field option to the IsRequired option in the Javascript API.
It really is amazing what we can do with the software.
I was wondering how our community handle this validation scenario regarding required fields that are located in tabs or sections.
I have a add page, on the add page there are 5 tabs, on the 3rd tab I have two fields that are required.
The users moves along the tabs but they forget to add any data to the required fields on tab 3. (Even after highlighting the required fields via Javascript)
The user is now on the final tab, they press the save button, to the user nothing happens, the record will not save because the user never added data to the required fields on tab 3, without a message telling them this the user would have to manually click back to the 3rd tab to see the "red required field warning" that appears on the required field after they tried to save the record without adding the required data.
Therefore I am somewhat reluctant to add required fields to tabs or sections.
I was wondering how anyone else out there handles this scenario. Is there a way to using tabs/sections...
or
I would love to hear your thoughts, workarounds or solutions on this.
Many thanks,

J


In 9.8 or below , just change the SAVE button "text" to NEXT instead of Save, and move along each tab. easier with no coding. They should not get past a tab that has a required field when they click next. What version and build are you using???
In 10.2 I would also like to know how to avoid this as I see now you can just switch tabs when a field is required. This will not work needs some attention . ????? Your right you should not be able to switch tabs if a field is required??

May need to change the form to have seperate controls and labels. I need to test that as it should warn you before going to the next tab. Great Question!
.

woodey2002 author 9/6/2019

Thanks for the response guys, much appreciated.
I'm currently using version 10.2, which is amazing.
Still looking for solution, currently looking at the tab Javascript API to possibly make the other tabs disabled if the a required field is not completed by the user.
I'm also looking at maybe a "before record added event" to check for black required fields and echo a message to the user the required field names they missed, or even just a message letting them know that they have missed some required fields.
I will post a solution if I find one <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=88724&image=1&table=forumreplies' class='bbc_emoticon' alt=':blink:' />.
Cheers

James

woodey2002 author 9/10/2019

Hi Guys,
So here is my solution using a little bit of Javascript.
It is a little long-winded but works well with sections( Not tested with tabs yet)
So I have 2 required fields horsepower1 and horsepower2, both are required and bothj located in seperate sections.
This code will see if the field is blank, notify the user with message, expand the section (if collapsed) and setFocus on the first missing required value).



var ctrlHorsepower1 = Runner.getControl(pageid, 'Horsepower1');

var ctrlHorsepower2 = Runner.getControl(pageid, 'Horsepower2');

var sec = pageObj.getSection(0);

var sec1 = pageObj.getSection(1);
this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){
if (!ctrlHorsepower1.getValue()){

ctrlHorsepower1.setFocus();

sec.expand();

alert( "You have not completed Horsepower1 field." );
}
});
var ctrlHorsepower2 = Runner.getControl(pageid, 'Horsepower2');

var sec1 = pageObj.getSection(1);
this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){
if (!ctrlHorsepower2.getValue()){

ctrlHorsepower2.setFocus();

sec1.expand();

alert( "You have not completed Horsepower2 field" );
}
});


It works well but I feel a Javascript wizz can help us improve it easily.
Hope this helps someone.
Cheers,

James