Using Before Save / Field validation
Posted: Thu Jun 17, 2021 2:14 am
I have some fields on my form that I want to make sure that they are completely filled in according to a certain format. They can't be entered partially. They must be a certain length and format BEFORE I can save them to the database.
For example a phone number.
I have a field for phone number that MUST be entered as ###-###-#### I do not want them to enter the number as ###-####.
Where in the form can I put the code to check the length and format of this field BEFORE SAVING it and if it is not entered exactly according to the format, I do not want to allow them to save the data. Should this be done in JAvascript (The forms custom code) or should this be done int he BEFORE SAVE code (which is PHP - sever side) ALL I want to happen is if the user clicks the save buttonm then the validation of the screen data occurs. if it fails, then I want to return to the edit screen with a JavaScript alert displayed.
I've done this many times with my own custom forms that I've built, using java script, but I don't know how to do it with the SAVE button in nuBuilder running its own function. How can I run this JavaScript to cancel the Save function when the user clicks it if my field validation fails?
For example a phone number.
I have a field for phone number that MUST be entered as ###-###-#### I do not want them to enter the number as ###-####.
Where in the form can I put the code to check the length and format of this field BEFORE SAVING it and if it is not entered exactly according to the format, I do not want to allow them to save the data. Should this be done in JAvascript (The forms custom code) or should this be done int he BEFORE SAVE code (which is PHP - sever side) ALL I want to happen is if the user clicks the save buttonm then the validation of the screen data occurs. if it fails, then I want to return to the edit screen with a JavaScript alert displayed.
I've done this many times with my own custom forms that I've built, using java script, but I don't know how to do it with the SAVE button in nuBuilder running its own function. How can I run this JavaScript to cancel the Save function when the user clicks it if my field validation fails?