two functions with same trigger
Hi Guys!
I've got a small problem with my webform. One function is validating my form and the other sends it via ajax to a php file where all the mysql stuff is executed.
Both functions use submit as a trigger and the submit function should only be called if the validation is successfull. I read stuff about callbacks and preventDefault but I don't get it runnin'.
- $(document).ready(function(){
- $("#inputInfos").submit(function(){
- // formvalidation
- });
- });
- $(document).ready(function(){
- $("#inputInfos").submit(function(){
- // ajax form submit
- });
- });
And because I'm a regex beginner too, here another question. In my validation class I check three diffrent types of input fields. Most of all is working, but please check if there are possible improvements on my code (and I bet there are!), thanks.
- only numbers, min 1 and max 20 characters long, no dots, commas, whatever --> WORKS
- if (!/^([\d]{1,20})$/.test(input.val())) {
- a select box with default value "select object", value != default value --> WORKS
- if (!/^[^select].*$/.test(charclass.val())) {
- the tricky one... only space(s), numbers and alphabetic characters only, no space at start or in the end (doesn't work), no double spaces, 3-20 chars.
- if (!/^[^ ](?!.*[ ]{2})([a-zA-Z0-9 ]{3,20})/.test(name.val())) {
Greetings Fabio