View Full Version : how to include javascripts in php page

01-23-2007, 12:46 PM
i need to know how to include form validation javascripts in php page and also
html javascripts for validate whether numeric or alphabetic data in a textbox needed

plz help

01-23-2007, 04:18 PM
Javascript runs on the client. PHP runs on the server prior to the page being served to the client.
PHP cannot use javascript code to do validation. You can certainly include the js file just like any normal include with the <script> tag (src attribute), but it will run on the client after the PHP has already completed running.

Code the validation in PHP if you need it done on the server (and you should; any validation done as a courtesy to the client on the client side using javascript should be duplicated on the server side for clients that do not have script and malicious clients who purposefully disable/alter it).