|
Not logged in [Login - Register] |
You Are Not Registered Or Not Logged In |
Corsa Sport » Message Board » Off Day » Geek Day » JQuery Again (lol) » Post Reply
|
Brett |
posted on 2nd Mar 15 at 22:01 |
Well, it just kept annoying me so I did it a different way entirely and this works perfectly :lol: Job done I guess. Cheers for your time Dom :) code: | |
Brett |
posted on 2nd Mar 15 at 20:09 |
I'll take a look. The strange bit is the number increase and padding works exactly how it should implying the if is correct. Once the form submit is added also the it just submit straight away on page load whether or not required text is present. Strangely, it behaves perfectly in an old browser like IE8, but when in a later version or Chrome it behaves incorrectly as described. I'll stick an alert in tho and see what's happening :thumbs: | |
Dom |
posted on 2nd Mar 15 at 19:31 |
quote: Can you not deal with that server-side? That'd be the typical route for something like this...... Although if i'm understanding you correctly, the user submits the form (/page) and an error is returned which is requiring you to re-submit the page with the adjusted data; if that's the case then what you had original should work, ie - on page load/ready you check for the error and re-submit the form. Is your IF statement firing correctly on page load (stick an alert in place of the .submit() to test) / Is 'poo' returning a value? Is the JQuery selector working correctly (perhaps use an ID attribute on the form tag and use vanilla JS - http://www.w3schools.com/jsref/met_form_submit.asp)? | |
Brett |
posted on 2nd Mar 15 at 10:23 |
Cheers Dom. I think doing it on the form submit or click event is the right way to go here actually. I can't get it to work though :| quote: Bit of background what this is for.. What happens is a user will submit the form. Occasionally if two users have tried to at once then it'll come back and give that 'primary key' error on the screen. What my code does then is take the next sequential number so there's no conflict and automatically resubmit. This is so the user doesn't really know what's going on. [Edited on 02-03-2015 by Brett] | |
Dom |
posted on 2nd Mar 15 at 09:38 |
Either you intercept the forms submit event - code: Or, replace the form's submit button with a 'vanilla' button (give it an id or name attribute) and trigger it all off a .click() event - code: Edit - If going down the button route, then you'd probably want to disable the forms default submit event as it might be possible for a user to trigger a submit off a form elements key press. [Edited on 02-03-2015 by Dom] | |
Brett |
posted on 1st Mar 15 at 23:08 |
What have I done wrong below? |