w3schoon Posted February 14, 2013 Share Posted February 14, 2013 Nice be with you everyone! Can you give some tutorials about Validates Form using PHP with Ajax & JQuery? I red that it is the best practice... Link to comment Share on other sites More sharing options...
Ingolme Posted February 14, 2013 Share Posted February 14, 2013 Best practise involves pure Javascript on the client-side and PHP on the server-side. AJAX would just slow down the process. Validation, both on the client side and on the server side, is just comparing the form element's value to what you want it to be. Link to comment Share on other sites More sharing options...
w3schoon Posted February 15, 2013 Author Share Posted February 15, 2013 (edited) I'm start confusing now for what you had said, I red that Ajax can do... 1. Live username checking2. Password confirmation and strength3. Checking if an email address is already registered4. URL validation, i.e. Basecamp's site address checks if the URL is available (pretty much the same as username validation) from: http://jqueryfordesi...validate-forms/ Can you tell me whyAJAX would just slow down the process. -Ingolme? The reason why I became interested to use Ajax for validation of form is because of this http://jqueryfordesigners.com/demo/ajax-validation.php (do not click the link but copy & paste it in the URL bar) Edited February 15, 2013 by w3schoon Link to comment Share on other sites More sharing options...
Ingolme Posted February 15, 2013 Share Posted February 15, 2013 Well, yes. I wouldn't call that validation. AJAX is the only way to check the existence of usernames, email addresses and URLs because they're outside of Javascript's capability. But I wouldn't send a request to the server just to check that a field was left empty or the the username has valid characters. Asking the server to do that with AJAX would be slower than just checking it with Javascript. If you're using AJAX to submit and process the form after the data has been validated then, yes, you don't need to worry about pure client-side validation. Link to comment Share on other sites More sharing options...
w3schoon Posted February 15, 2013 Author Share Posted February 15, 2013 (edited) Thank you for the reply. After reading your replies, I came up with two questions: #1. What do you mean, If you're using AJAX to submit and process the form after the data has been validated then, yes, you don't need to worry about pure client-side validation. -Ingolme?Isn't it the PHP & not the Ajax that will do the job of submitting and processing the form after the data has been validated? #2. What do you mean, Best practise involves pure Javascript on the client-side -Ingolme ?You mean I should only use pure Javascript for client-side validation & not with the JQuery or any other Javascript libraries? Sorry If I have too many questions, I just really want to learned from the experts Edited February 15, 2013 by w3schoon Link to comment Share on other sites More sharing options...
xekon Posted February 18, 2013 Share Posted February 18, 2013 (edited) Hi w3schoon, I actually am in the process of finishing up a registration form that uses PHP with Ajax & JQuery. If you do your initial sanity checks in pure Javascript as Ingolme suggests then you can minimize the amount of requests to the server, then once you pass the initial javascript comparative checks you can pass your values with ajax so you can do things like checking if a username is available or not. I may even do some more pure javascript checks on my data just to minimize work on the server, however a registration page wont get worked nearly as much as other forms on the site. to your question:"Isn't it the PHP & not the Ajax that will do the job of submitting and processing the form after the data has been validated?" you can use php directly to submit and process the form, but this would cause you to leave your current page, so lets say you submit your data, the page would then have to go to another page or reload the current page, but with Ajax, you can verify if the username is already taken, without the need to reload the page. Edited February 18, 2013 by xekon Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now