Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

JavaScript submit before PHP?

Featured Replies

I'm making a website and I want it to run perfectly without Javascript, but when Javascript is enabled that there are a couple of enhancements like a form validation without reloading the page. Of course, if the user has Javascript disabled I want the website to work to and go on with the PHP. So my question is: how do I run Javascript if javascript is enabled and run PHP when it's disabled? I'm quite new to Javascript and googled some stuff but didn't find anything useful.

You don't. You run PHP validation AND JavaScript validation. That way, when they don't have JS enabled, it doesn't fail to validate, and when they do, you don't waste bandwidth on a server-side validation request.

Edited by andyl

  • Author

You don't. You run PHP validation AND JavaScript validation. That way, when they don't have JS enabled, it doesn't fail to validate, and when they do, you don't waste bandwidth on a server-side validation request.

Then how do you make it so if Javascript is enabled it stops the PHP validation that goes to another page? Because I don't want it to go to another page when JS is enabled.

Edited by Dreeass

You'll need to stop the form submitting, using return false, or e.preventDefault() if you're using jQuery.

 

It's best practice to validate server-side every time. People can bypass validation by simply changing the JS functions on your page. They can't do that with server-side scripts.

Edited by andyl

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.