peri hoki perihoki clarustologistics rimashaop.com pola taktis menang gates of olympus x1000 perihoki pemain perihoki bongkar trik jepep starlight princess x1000 perihoki beri panduan lengkap bermain mahjong ways 2 pgsoft tips cara penghasil uang pgsoft mahjong ways 2 perihoki mahjong wins 3 perihoki memberikan penggali terbesar fenomena gates of olympus buka peluang besar bagi duta76 cara dapat pola emas rahasia di duta7 wild west gold trik menang pgsoft mahjong ways 2 modal receh maxwin duta76 duta76 main pgsoft mahjong ways 2 di sela istirahat scatter hitam mahjong wins 3 spin pasti jepe duta76 perihoki spin mahjong ways 2 pgsoft scatter hitam maxwin simbol mahjong wins 3 yang sering muncul di awal perihoki trik gampang menang mahjong wins cuan mahjong wins 3 tanpa henti pola spin taruhan kecil mahjong wins strategi kunci scatter hitam beruntun gacor total mahjong ways kemenangan maksimal mahjong ways kemenangan pria pekanbaru mahjong ways mahjong wins3 fenomena baru sumatera barat menangkan mahjong dengan lincah menembus batas keberuntungan mahjong ways menjajal keberuntungan di mahjong ways pola gratis mahjong ways1 scatter hitam senjata rahasia mahjong wins teknik spinning menguntungkan untuk scatter hitam analisis rtp tertinggi mahjong wins fenomena scatter hitam mahjong wins ibu rumah tangga dan keberuntungan mahjong keseruan main mahjong wins3 menang mahjong pengguna baru di sosial media menghargai setiap momen di mahjong ways serunya main mahjong di warung internet spin slow motion mancing scatter strategi jitu maxwin mahjong ways strategi jitu menang mahjong modal kecil jackpot besar anak kampung papua menggemparkan mahjong keajaiban scatter hitam mahjong ways keberhasilan joni mahjong wins kejaiban mahjong ways di ujung jalan ketua mahjong wins3 kehadiran kemenangan dimulai dari bali mahjong kehadiran yang menguntungkan mahjong menggila adat88 panduan kilat raih 108 juta tips memenangkan mahjong barista kopi menang 110 juta spin mahjong dakota76 scatter hitam mahjong wins 3 gagal cpns menang mahjong wins 3 rp120 juta kisah karyawan minimarket dapat thr lebih awal mahjong wins kisah pelajar sma kuasai mahjong wins 3 inspirasi sekolah kisah penjaga parkir tanah abang motor baru mahjong wins kisah sukses ibu rumah tangga bandung mahjong wins mahasiswa kkn beli iphone15 mahjong wins3 dakota mantan anak band influencer mahjong scatter hitam pola rtp senin gates of olympus guru matematika idola scatter hitam gampang meledak idola sensasi jackpot idola pola scatter hitam idola hasilkan jackpot dalam waktu singkat idola mahjong wins 3 bocor tukang cuci motor menemukan keberuntungan di mahjong
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 282
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_cookie_params(): Cannot change session cookie parameters when headers already sent
Filename: Session/Session.php
Line Number: 294
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 304
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 314
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 315
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 316
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 317
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 375
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: drivers/Session_files_driver.php
Line Number: 108
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_save_handler(): Cannot change save handler when headers already sent
Filename: Session/Session.php
Line Number: 110
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_start(): Cannot start session when headers already sent
Filename: Session/Session.php
Line Number: 143
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
Tạo một component PasswordStrengthChecker trong ReactJS
REACTJS EXAMPLE
CÁC CHỦ ĐỀ
BÀI MỚI NHẤT
Tạo một component PasswordStrengthChecker trong ReactJS
An toàn mật khẩu là một chủ đề quan trọng trong phát triển ứng dụng web ngày nay. Trong bài tập này, mình sẽ xây dựng một Password Strength Checker
bằng ReactJS để giúp người dùng đánh giá độ mạnh của mật khẩu họ đang sử dụng. Tạo một component PasswordStrengthChecker có chứa một ô nhập mật khẩu (input). Khi người dùng nhập mật khẩu, hiển thị mức độ mạnh yếu của mật khẩu dựa trên các quy tắc nhất định (ví dụ: ít nhất 8 ký tự, có chữ hoa, chữ thường, số, và ký tự đặc biệt).
Password Strength Checker bằng ReactJS
File: src/components/PasswordStrengthChecker.js
import React, { useState } from 'react';
import './PasswordStrengthChecker.css';
const PasswordStrengthChecker = () => {
const [password, setPassword] = useState('');
const calculateStrength = () => {
const hasUpperCase = /[A-Z]/.test(password);
const hasLowerCase = /[a-z]/.test(password);
const hasDigit = /\d/.test(password);
const hasSpecialChar = /[!@#$%^&*()_+{}\[\]:;<>,.?~\\/-]/.test(password);
if (password.length >= 8 && hasUpperCase && hasLowerCase && hasDigit && hasSpecialChar) {
return 'Mạnh';
} else if (password.length >= 6 && (hasUpperCase || hasLowerCase) && (hasDigit || hasSpecialChar)) {
return 'Trung bình';
} else {
return 'Yếu';
}
};
const handlePasswordChange = (e) => {
setPassword(e.target.value);
};
return (
<div className="password-strength-checker">
<label htmlFor="passwordInput">Password:</label>
<input
type="password"
id="passwordInput"
value={password}
onChange={handlePasswordChange}
/>
<p>Password Strength: {calculateStrength()}</p>
</div>
);
};
export default PasswordStrengthChecker;
File: src/components/PasswordStrengthChecker.css
/* src/components/PasswordStrengthChecker.css */
.password-strength-checker {
padding: 20px;
border: 1px solid #ccc;
margin-top: 20px;
}
/* Style cho input và label */
label {
display: block;
margin-bottom: 10px;
}
input {
width: 100%;
padding: 8px;
margin-bottom: 10px;
}
/* Hiển thị mức độ mạnh yếu của mật khẩu */
p {
font-weight: bold;
color: #333;
}
File: src/App.js
import React from 'react';
import PasswordStrengthChecker from './components/PasswordStrengthChecker';
const App = () => {
return (
<div>
<h1>ReactJS Handling Events Exercises</h1>
<PasswordStrengthChecker />
{/* Import và thêm các component khác ở đây */}
</div>
);
};
export default App;
File: src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
Kết quả:
Mình đã thành công tạo ra một Password Strength Checker sử dụng ReactJS. Component này không chỉ giúp người dùng kiểm tra độ mạnh của mật khẩu mà còn là một ví dụ tốt về cách sử dụng các sự kiện (event) trong React để tương tác với người dùng.
Hãy tiếp tục thực hành và áp dụng những kiến thức đã học vào các dự án ReactJS của bạn!
Bài giải
-------------------- ######## --------------------
Câu hỏi thường gặp liên quan:
Cùng chuyên mục: