'To prevent user from enabling button using inspect element
We are using a submit button in a timesheet which gets disabled once the month is finished. User cannot submit on next month. Problem some user go to inspect element and remove disabled and submit the form.
<a id="submit_time_sheet_id" href="javascript:void(0);"
onclick="isAllDaysPunched()" class="btn btn-xs btn-primary"
disabled="disabled">FinalSubmit</a>
User removes disabled="disabled" and form gets submitted.How to prevent user from modifying code
Solution 1:[1]
This will always be possible. You can't prevent anyone from using the developer tools to manipulate your form. That's why you always have to check data sent to the server server side.
Solution 2:[2]
“How to prevent user from modifying code?”
The answer is: you can't. How your website is opened is absolutely only decided by the respective user. Any person may download the HTML/JS/CSS source code of your website and modify it according to their needs. Or they directly invoke the form submit using tools like cURL.
The only way to prevent the submitting of data in a specified period, is to check the state – whether a user can submit data or not –on the server-side.
Solution 3:[3]
According to this Answer you can recheck your validations in the submit action.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | KooiInc |
| Solution 2 | feeela |
| Solution 3 | Nusri Nalir |
