Hey guys. I have a simple login form (username, password, but the fields are not important). So, what I want to do is: the user types in the data, clicks the submit button and if the data is incorrect to be displayed some kind of message like: 'wrong data'. I don't want to have javascript validation. I want only server side validation. So, when javascript is turned on, an ajax request is send to the server to a function to check the data. But, if javascript is turned off for some reason on the user's computer, I want the page to refresh and show the error message or if the data is correct, the user should be redirected to the index page. I hope I made the question clear enough Cheers ;)

I think you didn't understand me. I want when js is ON to make the validation via ajax request (so that the page won't refresh) and when it is turned OFF when I click the submit button the page should be refreshed and the err/success messages should be displayed properly.That is because with js you can do validations like "Field is empty", "Field is more than 20 symbols" but you can't check if this user and pass are in the db and are the correct info (you can't do db checks and manipulations). This is done with ajax request -> php script that checks if the password is for this user etc. etc. That's why I think I don't really need only js validation - I can do all the validation with php and then return a message - "Success", "Field is empty" etc. etc. I'm not saying it's the best practice but I personally would do it like that.

okay, I think I found a workaround. I haven't tried it, but when I do, I'll post results. I'm giving the simplest example: you have a form with a submit button. You set onClick on the submit button to some js function whete the ajax is called. At the very beginning of that function you call: submit_button.preventDefault. This way, if js is enabled you will stop the form from submitting and make the ajax call. If js is disabled - the form will simply submit, because the preventDefault will not be executed. Hope this works