vijay587 Posted August 1, 2012 Report Posted August 1, 2012 Which programming(javascript or PHP) I have need to use to check the form fields such as textbox cannot be empty, password field must contain special symbol, Email ID format is valid or not etc. Quote
Andrea Posted August 1, 2012 Report Posted August 1, 2012 Go with PHP - JavaScript can be turned off client-side. BTW - Java and JavaScript are TWO totally different things. Quote
falkencreative Posted August 1, 2012 Report Posted August 1, 2012 Why PHP? As Andrea said, because PHP can't be turned off. A visitor to your site can easily disable Javascript, meaning that your form may not work as intended. Quote
Andrea Posted August 1, 2012 Report Posted August 1, 2012 JavaScript can be turned off client-side. I'm not an expert in this, but this I know. Quote
markvs Posted February 4, 2013 Report Posted February 4, 2013 (edited) For those with JavaScript available - I would think that you could do some simple verification using JavaScript before submitting the form. And then do a more thorough validation using php and Regular Expressions. I'm also far from an expert, but I've read that somewhere and it would make for a better user experience for most. Edited February 4, 2013 by markvs Quote
Andrea Posted February 4, 2013 Report Posted February 4, 2013 That doesn't make sense to me - if PHP takes care of everything for everybody, why also muddle with a partial solution that only works for some? Not sure what kind of a user experience you are thinking of providing - we're talking form validation. Quote
markvs Posted February 4, 2013 Report Posted February 4, 2013 Before you send the form to the server to be processed by the php interpreter, it would be nice if all of the required fields had some data; preferably in the correct format. eg. An email address could be checked to make sure it had some minimal formatting, such as making sure it contained the "@" and "." symbols and this could be done by JavaScript on the clients computer. If a required field was left blank, that could be checked, etc. - all before you send a request to the server. Considering that a very large percentage of users have JavaScript turned on (over 97%, I think), it would be a good idea to use JavaScript and php to process a form. JavaScript to improve the user experience and take some of the load off of the server, and php to take care of the real processing which is much more secure than JavaScript. Like I said, I'm far from a pro, but this is what I've read. Quote
sudheerphp Posted February 5, 2013 Report Posted February 5, 2013 Hi, Mostly we use JavaScript for Client side validation,why because the network round trips between client and server is very mush reduced by using js, on the other hand PHP is used for communicating with the databases like MYsql,etc and retriving the data also. HTML+CSS -----> Designing purpose javascript ------>Validating and dynamic action purpose PHP/SOAP ------->Communicating with databases , for public and custom webservices. Mysql--------------->open source DB. Thank you. Regards sudheer.. Quote
LSW Posted February 5, 2013 Report Posted February 5, 2013 I would say PHP as well. Here at work we use Java and/or Classic ASP. In the Classic ASP apps I have been updating or maintaining we do use JS, but only as a mask, ensuring that the data fits the format requirements. So you can use JS to format a telephone number as you wish on the fly. Most folks (US) tend to write (555) 555-1234, but not all, so a JS mask can take any numbers and format it as the database needs it. Masking not only makes it easier for the user, but it can format the data or require data (not allow you to finish without an area code for instance.) The simple answer from me is PHP to flat out answer the question. That said, using the JS mask allows you to format the data as reqyuired for the database so all the PHP needs to do is validate rather than... IF telNr. is (XXX)XXX-XXXX add a space between ) & X IF telNr. is XXX XXX-XXXX add () around the first 3 didgits. etc. etc. etc. JS frees the PHP to do pure validation. So best is PHP and maybe do formatting requirements etc. with JS additionally. Quote
grabenair Posted February 6, 2013 Report Posted February 6, 2013 Just a note and off subject, has anybody noticed that this question was originally posted Aug. of last year. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.