Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validations #64

Merged
merged 2 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/src/components/common/Inputs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function TextInput({
onChange,
placeholder,
required,
pattern,
onInvalid,
}) {
return (
<label className="input input--text">
Expand All @@ -21,6 +23,8 @@ function TextInput({
value={value}
onChange={onChange}
required={required}
pattern={pattern}
onInvalid={onInvalid}
/>
</label>
);
Expand Down
12 changes: 9 additions & 3 deletions client/src/components/insert-scout/InsertScoutPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ const InsertScoutPage = () => {
name="firstname"
placeholder="جون"
value={firstName}
onChange={(e) => setFirstName(e.target.value)}
onChange={(e) => {setFirstName(e.target.value); e.target.setCustomValidity('');}}
pattern="^[\u0621-\u064Aa-zA-Z]+$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال الاسم الاول فقط (باللغة العربية او الانجليزية)')}
required={true}
/>
</div>
Expand All @@ -101,7 +103,9 @@ const InsertScoutPage = () => {
name="middlename"
placeholder="دوي"
value={middleName}
onChange={(e) => setMiddleName(e.target.value)}
onChange={(e) => {setMiddleName(e.target.value); e.target.setCustomValidity('');}}
pattern="^[\u0621-\u064Aa-zA-Z]+$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال الاسم الاوسط فقط (باللغة العربية او الانجليزية)')}
required={true}
/>
</div>
Expand All @@ -114,7 +118,9 @@ const InsertScoutPage = () => {
name="lastname"
placeholder="السيد"
value={lastName}
onChange={(e) => setLastName(e.target.value)}
onChange={(e) => {setLastName(e.target.value); e.target.setCustomValidity('');}}
pattern="^[\u0621-\u064Aa-zA-Z]+$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال الاسم الأخير فقط (باللغة العربية او الانجليزية)')}
required={true}
/>
</div>
Expand Down
8 changes: 6 additions & 2 deletions client/src/components/insert-sector/InsertSector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export default function InsertSector() {
type="text"
name="sectorBaseName"
value={sectorBaseName}
onChange={(e) => setSectorBaseName(e.target.value)}
onChange={(e) => {setSectorBaseName(e.target.value); e.target.setCustomValidity('');}}
pattern="^[\u0621-\u064Aa-zA-Z]+$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال أسم القطاع بطريقة صحيحة (بالعربية او الانجليزية)')}
placeholder="اسم القطاع"
required
/>
Expand All @@ -74,7 +76,9 @@ export default function InsertSector() {
type="text"
name="sectorSuffixName"
value={sectorSuffixName}
onChange={(e) => setSectorSuffixName(e.target.value)}
onChange={(e) => {setSectorSuffixName(e.target.value); e.target.setCustomValidity('');}}
pattern="^[\u0621-\u064Aa-zA-Z]+$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال رقم القطاع بطريقة صحيحة')}
placeholder="مثل: أ, ب, ج"
required
/>
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/login/logIn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export default function LogIn() {
name="email"
value={email}
placeholder="[email protected]"
onChange={(e) => setEmail(e.target.value)}
onChange={(e) => {setEmail(e.target.value); e.target.setCustomValidity('');}}
pattern="^[a-zA-Z0-9._%\+\-]+@[a-zA-Z0-9._%\+\-]+\.[a-z]{2,}$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال بريد إليكتروني صحيح')}
required={true}
/>
<TextInput
Expand Down
20 changes: 15 additions & 5 deletions client/src/components/signup/signUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export default function SignUp() {
name="firstName"
value={firstName}
placeholder="أكتب أسمك الاول"
onChange={(e) => setFirstName(e.target.value)}
onChange={(e) => {setFirstName(e.target.value); e.target.setCustomValidity('');}}
pattern="^[\u0621-\u064Aa-zA-Z]+$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال الاسم الاول فقط (باللغة العربية او الانجليزية)')}
required={true}
/>
<TextInput
Expand All @@ -89,7 +91,9 @@ export default function SignUp() {
name="middleName"
value={middleName}
placeholder="أكتب أسمك المتوسط"
onChange={(e) => setMiddleName(e.target.value)}
onChange={(e) => {setMiddleName(e.target.value); e.target.setCustomValidity('');}}
pattern="^[\u0621-\u064Aa-zA-Z]+$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال الاسم الاوسط فقط (باللغة العربية او الانجليزية)')}
required={true}
/>
<TextInput
Expand All @@ -98,7 +102,9 @@ export default function SignUp() {
name="lastName"
value={lastName}
placeholder="أكتب أسمك الأخير"
onChange={(e) => setLastName(e.target.value)}
onChange={(e) => {setLastName(e.target.value); e.target.setCustomValidity('');}}
pattern="^[\u0621-\u064Aa-zA-Z]+$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال الاسم الأخير فقط (باللغة العربية او الانجليزية)')}
required={true}
/>
</div>
Expand All @@ -110,7 +116,9 @@ export default function SignUp() {
name="email"
value={email}
placeholder="[email protected]"
onChange={(e) => setEmail(e.target.value)}
onChange={(e) => {setEmail(e.target.value); e.target.setCustomValidity('');}}
pattern="^[a-zA-Z0-9._%\+\-]+@[a-zA-Z0-9._%\+\-]+\.[a-z]{2,}$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال بريد إليكتروني صحيح')}
required={true}
/>
<TextInput
Expand Down Expand Up @@ -140,7 +148,9 @@ export default function SignUp() {
name="phone"
value={phone}
placeholder="أكتب رقم هاتفك"
onChange={(e) => setPhone(e.target.value)}
onChange={(e) => {setPhone(e.target.value); e.target.setCustomValidity('');}}
pattern="^01[0-9]{9}$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال رقم هاتف صحيح')}
required={true}
/>
<RadioInput
Expand Down
12 changes: 9 additions & 3 deletions client/src/components/update-scout/UpdateScoutPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ const UpdateScoutPage = () => {
name="firstname"
placeholder="جون"
value={firstName}
onChange={(e) => setFirstName(e.target.value)}
onChange={(e) => {setFirstName(e.target.value); e.target.setCustomValidity('');}}
pattern="^[\u0621-\u064Aa-zA-Z]+$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال الاسم الاول فقط (باللغة العربية او الانجليزية)')}
required={true}
/>
</div>
Expand All @@ -191,7 +193,9 @@ const UpdateScoutPage = () => {
name="middlename"
placeholder="دوي"
value={middleName}
onChange={(e) => setMiddleName(e.target.value)}
onChange={(e) => {setMiddleName(e.target.value); e.target.setCustomValidity('');}}
pattern="^[\u0621-\u064Aa-zA-Z]+$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال الاسم الاوسط فقط (باللغة العربية او الانجليزية)')}
required={true}
/>
</div>
Expand All @@ -204,7 +208,9 @@ const UpdateScoutPage = () => {
name="lastname"
placeholder="السيد"
value={lastName}
onChange={(e) => setLastName(e.target.value)}
onChange={(e) => {setLastName(e.target.value); e.target.setCustomValidity('');}}
pattern="^[\u0621-\u064Aa-zA-Z]+$"
onInvalid={(e) => e.target.setCustomValidity('الرجاء إدخال الاسم الأخير فقط (باللغة العربية او الانجليزية)')}
required={true}
/>
</div>
Expand Down