newbie asking about custom form validation
- Single Page
Posted 02 June 2013 - 16:53 PM
What is confusing me are:
1. How can I check values in the 2 fields and query db at the same time? I already searched about custom validation rules but I think I still need some help.
2. Let's say after db query i have to say to the user "sorry you cannot book at those time" via javascript alert box. I already made a callback before insert function which contains that code but it doesn't work.
Thanks before
Posted 02 June 2013 - 21:39 PM
Hello [member=Hary Law] and welcome to the forums.
This is not strictly Grocery CRUD question. It is more database/PHP/CodeIgniter question.
Just some pointers,
- when you want to access the database you use a function (or a function within a model) to access the database, check here: http://ellislab.com/codeigniter/user-guide/general/models.html
- when you want to validate a field you use the http://www.grocerycrud.com/documentation/options_functions/set_rules or better read from the official manual of CI, http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#validationrules
- if you properly use the validation rules an error message appears at the bottom of the form displaying the proper error message. If you need to display on an alert box just use the appropriate js code. FancyBox might be an option.
Posted 03 June 2013 - 04:54 AM
can you help me how to show a dialog confirmation box when i'm trying to insert data?
just like example 3 at
http://jquerymsgbox.ibrahimkalyoncu.com/
thank you
right now i have this simple function on callback insert to test wether i can show alert box or not
function postprocess1($post_array) { echo "<script type=\"text/javascript\">alert('Some text');</script>"; }
but it doesnt work, everytime i click on save it just says that operation succeeded but i couldn't get alert working.
Posted 03 June 2013 - 08:26 AM
As I said this question is not a Grocery CRUD related!
It seems that you need to study the way the PHP and Javascript interact.
The example 3 you mention is initiated via user when he presses the button. Javascript is on the client (user) side.
They don't answer your question but they will give you some direction.
You need to modify the way your theme works to have this implemented.