Working Example First, make sure all event handlers are attached once the DOM is ready I'm using submit() on the actual form $(document). Ready(function() { // now that document is "ready" $('#formId'). Submit(function() { var email = $('#emailInput').val(); alert(email); if(email.
IndexOf("@") == -1){ alert("invalid! "); return false; // cancel form submission if email invalid } alert("valid! "); return true; // return true if no errors once I get it working }); }).
Working Example First, make sure all event handlers are attached once the DOM is "ready" I'm using .submit() on the actual form. $(document). Ready(function() { // now that document is "ready" $('#formId').
Submit(function() { var email = $('#emailInput').val(); alert(email); if(email. IndexOf("@") == -1){ alert("invalid! "); return false; // cancel form submission if email invalid } alert("valid!"); return true; // return true if no errors once I get it working }); }).
This is what I thought too, but the OP has a comment at the top of their code block that indicates this didn't work for them either. – jadarnel27 Oct 3 at 16:06 Well I'm showing that in fact it does... so if this does not work, there are errors in code we have not yet seen... – jondavidjohn Oct 3 at 16:07 Oops, that makes sense. +1 then =) – jadarnel27 Oct 3 at 16:07 Well, this got me up and running.
Thank you all for your help! – Zach L. Oct 3 at 17:04.
Try wrapping your code in a ready block. $(document). Ready(function(){ // your code here }); You should also be using the submit event on the element, I think.
I'm constantly forgetting that even though my click events never run until after the page is loaded, they're still attached to selectors that won't match anything before $(document).ready. – mblase75 Oct 3 at 16:09.
This is going to work. If you don't understand why, feel free to ask :) var validated = false; $(document). Ready(function(){ $("#rfq").
Submit(function(event) { if (validated === true) { return true; } event.preventDefault(); // prevent submission var email = $('#email').val(); if(email. IndexOf("@") == -1){ $("#email"). AddClass('invalid'); return; } validated = true; return $(this).
Trigger('submit'); }); }).
You could try using this function to validate your address. Function validateEmail(elementValue){ var emailPattern = /^a-zA-Z0-9. _-+@a-zA-Z0-9.
-+\. A-zA-Z{2,4}$/; return emailPattern. Test(elementValue); } And then modify your code to submit the form.
$('#submit'). Click(function() { var email = $('#email').val(); if(!validateEmail(email)){ $("#email"). AddClass('invalid'); } else { $("form").submit(); } }).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.