Jump to content


Photo

Webdevelopment


  • Please log in to reply
10 replies to this topic

#1 vijaypatial

vijaypatial

    New member

  • New Members
  • 3 posts
  • Facebook:vijayITprofessional
  • LocationIndia

Posted 01 August 2012 - 12:24 PM

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.
  • 0

#2 Andrea

Andrea

    Advanced Member

  • Moderators
  • 5,752 posts
  • Facebook:https://www.facebook.com/aandbwebdesignAB
  • LocationSadieville, KY - but always a Texan at heart!!

Posted 01 August 2012 - 12:27 PM

Go with PHP - JavaScript can be turned off client-side.

BTW - Java and JavaScript are TWO totally different things.
  • 0

#3 vijaypatial

vijaypatial

    New member

  • New Members
  • 3 posts
  • Facebook:vijayITprofessional
  • LocationIndia

Posted 01 August 2012 - 12:29 PM

Why PHP?
  • 0

#4 Ben

Ben

    Administrator

  • Administrators
  • 5,682 posts
  • LocationGainesville, Florida

Posted 01 August 2012 - 01:47 PM

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.
  • 0
Benjamin Falk
Falken Creative : Twitter

#5 Andrea

Andrea

    Advanced Member

  • Moderators
  • 5,752 posts
  • Facebook:https://www.facebook.com/aandbwebdesignAB
  • LocationSadieville, KY - but always a Texan at heart!!

Posted 01 August 2012 - 02:10 PM

JavaScript can be turned off client-side.


I'm not an expert in this, but this I know.
  • 0

#6 markvs

markvs

    Member

  • Member
  • PipPip
  • 27 posts

Posted 04 February 2013 - 12:33 PM

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 by markvs, 04 February 2013 - 12:40 PM.

  • 0

#7 Andrea

Andrea

    Advanced Member

  • Moderators
  • 5,752 posts
  • Facebook:https://www.facebook.com/aandbwebdesignAB
  • LocationSadieville, KY - but always a Texan at heart!!

Posted 04 February 2013 - 12:57 PM

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.
  • 0

#8 markvs

markvs

    Member

  • Member
  • PipPip
  • 27 posts

Posted 04 February 2013 - 02:45 PM

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.
  • 0

#9 sudheer

sudheer

    New member

  • New Members
  • 8 posts

Posted 05 February 2013 - 02:37 AM

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..:mellow:
  • 0

#10 LSW

LSW

    Knight of the Square Cubicle

  • Moderators
  • 8,073 posts
  • LocationJuneau AK

Posted 05 February 2013 - 11:55 AM

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.
  • 0

Thank You, Migwetth, Gunalche’esh, Ha’w'aa, Danke
 

"There are 3 types of people: Those who can count and those who cannot."

 


#11 grabenair

grabenair

    Advanced Member

  • Member
  • PipPipPipPip
  • 361 posts
  • LocationIowa

Posted 05 February 2013 - 09:27 PM

Just a note and off subject, has anybody noticed that this question was originally posted Aug. of last year. :)
  • 0
Standards will change. But your website needs to remain in serving its audience.
My Portfolio site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

★★★★★ 5 Star Rated Web Developer Course - check it out now!