JavaScript 유효성 검사가 나쁜가요?
JavaScript를 사용하여 양식의 유효성을 검사 한 지 오래되었습니다. 나는 이것이 대부분의 다른 개발자들에게 해당 될 것이라고 확신합니다.
질문:
사용자 (또는 악의적 인 사람)가 JavaScript를 비활성화하면 어떻게됩니까?
당신이졌다!
- JavaScript 유효성 검사가 그만한 가치가 있습니까?
- 지금 사용해야하나요?
- 이에 대한 해결책이 있습니까?
내가 틀렸다면 정정하십시오.
JavaScript 유효성 검사가 그만한 가치가 있습니까?
예, 더 나은 사용자 경험을 제공하고 대역폭을 보존합니다.
지금 사용해야하나요?
예, 앞서 언급 한 이유 때문입니다.
이에 대한 해결책이 있습니까?
예, 서버 측 유효성 검사도 사용합니다.
사용자 (또는 악의적 사용자)가 자바 스크립트를 비활성화하면 어떻게됩니까?
이전에 말했듯이 : 단순히 클라이언트에 의존하지 마십시오. 그렇게하지 마십시오. 서버의 모든 것을 다시 확인하십시오.
지금 사용해야하나요?
예-사용자는 즉시 무엇이 잘못되었는지 확인합니다. 그렇지 않으면 먼저 데이터를 다시 게시해야하는데 시간이 걸릴 수 있습니다. 그런데 서버에 대한 트래픽을 줄입니다.
단순히 더 직관적입니다.
// 편집 : BTW : ASP.NET ValidationRules에는 내가 아는 한 클라이언트 측 및 서버 유효성 검사가 모두 포함되어 있습니다.
Javascript 유효성 검사는 더 나은 사용자 경험을 제공하기 때문에 좋습니다.
당신은 그러나한다 결코 에 의존하지 관계없이 서버에서 확인해야합니다.
시간을 절약하려면 서버 측만 사용하십시오. 더 나은 성능과 사용자 경험을 원한다면 나중에 클라이언트 측 유효성 검사를 추가하십시오. 명시한 이유로 클라이언트 측 유효성 검사에 의존하지 마십시오. 모든 중요한 유효성 검사는 클라이언트에서 복제 되더라도 서버에서 발생해야합니다.
JavaScript는 제품 또는 서비스에 대한 사용자 상호 작용 을 개선 합니다. 사용자 상호 작용 (사용자 입력 및 기계 응답 또는 그 반대)은 당사 애플리케이션의 중요한 특성입니다. 우리 모두 경험했듯이, 제품은 그 어느 때보 다 상호 작용이 향상되고 있습니다. 이 상호 작용 부분은 JavaScript ( ActionScript for Flash Player ) 로만 제작할 수 있습니다 . 우리 모두는 이것에 동의 할 것입니다. 서버로 보내지 않고 호출을 피하기 위해 클라이언트 측 (기계)으로 전송할 수있는 계산 된 작업량이 항상 있습니다. 클라이언트 스크립트 스크립팅에 크게 의존하는 많은 응용 프로그램이 있습니다. 그리고 그들이 필요한 스크립팅을 허용하지 않는다는 것을 발견하면 메시지를 남기고 요청했습니다.noscript
꼬리표. 그러나 우리 모두 Gmail, Facebook 등으로 탭을 시작하기 때문에 모든 사람이 활성화하기를 원한다고 생각합니다.
그러나 우리는 모든 단일 기회 (청중 / 고객)를 포착하기를 열망하고 협력하는 것이 적어도 떨어져 나가는 것보다 낫기 때문에 여전히 무시해서는 안됩니다. 여전히 작동합니다!
Microsoft Development Platform 사용자로서 플랫폼에 편리한 솔루션이 .NET
있습니다. 그러한 문제에 대해 이중 노력이 필요하지 않습니다. 클라이언트 측 유효성 검사의 만들기 사용은 동안 스크립트 비활성화되어 사용 Page.Validate()
하고 Page.IsValid
.
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack) {
Page.Validate(); // If you missed, then you got the second chance ...
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (Page.IsValid) { // Confirm you do a proper validation before moving to perform any process
Response.Write("Done!");
}
}
이것이 도움이되기를 바랍니다.
클라이언트 측 (자바 스크립트) 유효성 검사는 유용성에 관한 것입니다. 구현 비용이 유용성 증가에 비해 가치가없는 경우 시간을 낭비하지 마십시오. 요즘에는 아주 쉽게 할 수 있습니다!
그러나 이것이 보안을 제공하는 유일한 방법이기 때문에 서버 측 유효성 검사 없이는 할 수 없다고 생각합니다.
JavaScript를 사용하는 것은 잘못된 것이 아닙니다. 우리는 오랫동안 사용하고 있습니다. 클라이언트 측 유효성 검사를 적용하는 데 사용됩니다.
그럼에도 불구하고 우리는 나쁜 사람 이 응용 프로그램을 손상시킬 수 없도록 서버 측 유효성 검사를 구현해야 합니다.
이 주제에서 한 가지만 배우면 다음과 같이하십시오.
어떤 상황에서도 브라우저의 데이터를 신뢰하지 말고 항상 서버 측에서 요청 데이터의 유효성을 검사하십시오.
지금 사용해야하나요?
Yes, definitely. You do not need to validate an empty field on the server side. It is not something like validating an email's availability (uniqueness of email). If you are going to reject that empty field anyway, there is no point of sending it to server and making server do extra work for it.
You have to validate it on sever-side, javascript is good to validate form, but people can disable javascript, or use another javascript to hack it, so validation on server-side is a must.
JavaScript is useful for client side validation. But you cannot rely only on them. You must use server-side validation against the posted data. JavaScript just prevents unnecessary posts to the server.
You can make server and client-side validation pretty painless by using a framework that supports both. In the past, for ASP.NET I used the Peter Blum validators:
With this, you drop the validation controls onto your page, hook them up to the inputs (textboxes, drop down lists etc), and specify the validation properties (minimum length, required, error message etc). When the page runs, the framework spits out equivalent code for both the client (JavaScript) and server (ASP.NET) to perform your validation.
Without such a framework, as other posters have pointed out, validation can be laborious.
I'd be interested to know of anything similar for PHP or other technologies.
You should have multiple layers of validation.
Validation on the client Side
This is definitely useful because validation can be done without having to go to the server. Requests get to the server once they are validated - saves some traffic.
Validation on the server side
If javascript is disabled then the server should also incorporate a level of protection - validation in order to disallow erroneous requests.
In a multi-tiered / service orientated environment validation should exist on multiple levels to allow for better reuse while still maintaining a secure application. Validation on the client side, whether in a desktop app, or web site/application should be there for a better user experience to prevent postbacks to the server everytime for validation, hence costing more bandwidth and user time. If client-side validation cannot be moved entirely to the front end then consider using ajax for a partial postback to a server side validation routine, while retaining a better customer experience but allowing a programmer to maintain the validation rules centrally.
Second to the client side, but more importantly, server side code should validate the data before persisting it via a data layer or passing it to another server side method/service, to employ business rules around the data and help prevent errors in data integrity. Lastly, the persistence layer itself (the immediate interface to the database or other storage mechanism) should validate the data being stored, again to prevent errors in data integrity and possibly further business rules. The last thing you want is a data store with useless data.
Employing this method will keep you data secure and integrity in line. On reuse of either you persistence layer, your data layer or your front-end presentation thereafter, in your own site (or via a web service, desktop application or mobile app), if designed properly, these validation routines are already in place and can be re-employed. This should prove to be of great benefit to you alone, and your colleagues and your management, if you happen work in a team.
Is JavaScript validation worth of it?
well,yes it is .Buy using JavaScript validation you can easily take any kind information about client site more over JavaScript validation provides a better user experience
Should we ever use it now?
Yes you can because of user can see there error or what's they do wrong on real-time
Are there any solutions to this?
yes you can also use server-side validation.But sometime its take more time .it's also insecure
참고URL : https://stackoverflow.com/questions/1945005/is-javascript-validation-bad
'Development Tip' 카테고리의 다른 글
모달 UIViewController의 애니메이션 스타일을 어떻게 변경할 수 있습니까? (0) | 2020.11.02 |
---|---|
MySQL은 큰 데이터베이스에서 중복을 빠르게 제거 (0) | 2020.11.02 |
Chrome에서 고정 요소가 사라짐 (0) | 2020.11.02 |
iOS에 키보드가 나타나면 UIView를 위로 이동 (0) | 2020.11.02 |
ajax 호출 후 jQuery 클릭 기능이 작동하지 않습니까? (0) | 2020.11.02 |