المكوّنات · تسجيل بحساب بنكي
تسجيل بحساب بنكي
الآيبان يُفحص بخوارزمية mod-97 كاملة لا بطوله
12 تصاميم من هذه العائلة
<div class="sg sgn">
<h5 data-ar="حساب التبرّعات" data-en="Donation account">حساب التبرّعات</h5>
<label><span data-ar="اسم صاحب الحساب" data-en="Account holder">اسم صاحب الحساب</span>
<input class="hn" type="text" placeholder="جمعية البرّ الخيرية"><span class="err"></span></label>
<label><span data-ar="رقم الآيبان" data-en="IBAN">رقم الآيبان</span>
<input class="ib" type="text" placeholder="SA00 0000 0000 0000 0000 0000" dir="ltr">
<span class="err"></span></label>
<div class="meta"><span class="bank"></span><span class="chk"></span></div>
<button class="go" disabled data-ar="ربط الحساب" data-en="Link account">ربط الحساب</button>
</div>
/* pt-scoped */
/* signup-iban — جمعية خيرية */
.sgn{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.sgn h5{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600}
.sgn .sub{margin:0;font-size:8.5px;color:var(--pt-text-muted)}
.sgn label{display:flex;flex-direction:column;gap:3px}
.sgn label > span{font-size:8.5px;color:var(--pt-text-muted)}
.sgn input, .sgn select{width:100%;font:inherit;font-size:9.5px;
color:var(--pt-text-primary);outline:none}
.sgn input::placeholder{color:var(--pt-text-muted)}
.sgn .err{font-size:8px;color:var(--pt-color-danger-400);min-height:0}
.sgn .ok{color:var(--pt-accent)}
.sgn button{font:inherit;cursor:pointer}
.sgn button:focus-visible, .sgn input:focus-visible{outline:2px solid var(--pt-focus-ring);
outline-offset:1px}
/* شخصية: مصرفية — انحناء صغير، خطّ أحادي، شارة تحقّق */
.sgn{padding:10px;gap:6px;justify-content:center;
border:1px solid var(--pt-border-default);border-radius:var(--pt-radius-sm);
background:var(--pt-surface)}
.sgn input{padding:6px 9px;border-radius:var(--pt-radius-xs);
border:1px solid var(--pt-border-default);background:var(--pt-bg-inset)}
.sgn .ib{font-family:var(--pt-font-mono);font-size:9px;letter-spacing:.06em;text-transform:uppercase}
.sgn input[aria-invalid=true]{border-color:var(--pt-color-danger-400)}
.sgn input[aria-invalid=false]{border-color:color-mix(in srgb,var(--pt-accent) 55%,transparent)}
.sgn .meta{display:flex;align-items:center;justify-content:space-between;gap:8px;
min-height:12px;font-size:8px}
.sgn .bank{color:var(--pt-text-secondary)}
.sgn .chk{font-weight:700}
.sgn .chk.ok{color:var(--pt-accent)}
.sgn .chk.bad{color:var(--pt-color-danger-400)}
.sgn .go{padding:7px;border-radius:var(--pt-radius-xs);border:0;background:var(--pt-accent);
color:var(--pt-color-ink-900);font-size:9.5px;font-weight:600}
.sgn .go:disabled{opacity:.45;cursor:not-allowed}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.sgn');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
/* الخطأ يظهر بعد مغادرة الحقل لا مع كل حرف: القراءة أثناء الكتابة
تُشعر المستخدم بالفشل قبل أن ينتهي من الإدخال. */
function bind(input, check, msg) {
var box = input.closest('label') || input.parentElement;
var err = box.querySelector('.err') || box.parentElement.querySelector('.err');
var touched = false;
function paint() {
var good = check(input.value);
input.setAttribute('aria-invalid', String(touched && !good));
if (err) err.textContent = touched && !good ? msg : '';
return good;
}
input.addEventListener('blur', function () { touched = true; paint(); });
input.addEventListener('input', function () { if (touched) paint(); });
return paint;
}
var hn = root.querySelector('.hn'), ib = root.querySelector('.ib');
var go = root.querySelector('.go');
var bank = root.querySelector('.bank'), chk = root.querySelector('.chk');
var BANKS = { '10': 'البنك الأهلي', '15': 'مصرف الإنماء', '20': 'بنك الرياض',
'45': 'البنك السعودي البريطاني', '80': 'مصرف الراجحي' };
function raw(v) { return String(v).toUpperCase().replace(/[^A-Z0-9]/g, ''); }
/* mod-97 كاملة: تُنقل الأحرف الأربعة الأولى إلى النهاية، ويُستبدل كل حرف
برقمه (A=10 … Z=35)، ثم يُقسَّم على 97 والباقي لا بدّ أن يكون 1.
الفحص بالطول وحده يقبل آيبانًا مكتوبًا خطأً فترتدّ الحوالة بعد أيّام. */
function mod97(v) {
var s = raw(v);
if (s.length !== 24 || s.slice(0, 2) !== 'SA') return false;
var re = s.slice(4) + s.slice(0, 4);
var rem = 0;
for (var i = 0; i < re.length; i++) {
var c = re.charCodeAt(i);
var part = c >= 65 ? String(c - 55) : re[i]; // A-Z ← 10-35
for (var k = 0; k < part.length; k++) rem = (rem * 10 + (+part[k])) % 97;
}
return rem === 1;
}
bind(hn, function (v) { return v.trim().length >= 4; }, 'الاسم قصير جدًّا');
bind(ib, mod97, 'رقم الآيبان غير صحيح — راجع الخانات');
function refresh() {
var ok = mod97(ib.value), s = raw(ib.value);
chk.className = 'chk ' + (s.length === 24 ? (ok ? 'ok' : 'bad') : '');
chk.textContent = s.length !== 24 ? s.length + ' / 24'
: ok ? '✓ mod-97' : '✕ mod-97';
bank.textContent = ok ? (BANKS[s.slice(4, 6)] || 'بنك محلّي') : '';
go.disabled = !(ok && hn.value.trim().length >= 4);
}
ib.addEventListener('input', function () {
var s = raw(ib.value).slice(0, 24);
// مجموعات من أربعة: العين تلتقط الخطأ في الرقم المقسَّم لا المتّصل
ib.value = s.replace(/(.{4})/g, '$1 ').trim();
refresh();
});
hn.addEventListener('input', refresh);
ib.value = 'SA44 2000 0001 2345 6789 1234';
refresh();
}
function mount() {
ac = new AbortController();
var real = window.document;
/* وسيط يمرّر كل شيء إلى المستند الحقيقي، ويعلّق كل مستمع بإشارة
تُقطع عند إعادة التركيب — فلا يبقى مستمع من نسخة ماتت. */
var doc = new Proxy(real, {
get: function (t, k) {
if (k === 'addEventListener') {
return function (type, fn, opts) {
var o = (opts && typeof opts === 'object') ? Object.assign({}, opts)
: { capture: !!opts };
o.signal = ac.signal;
return t.addEventListener(type, fn, o);
};
}
var v = t[k];
return typeof v === 'function' ? v.bind(t) : v;
}
});
function track(fn) {
return function (f, ms) { var id = fn(f, ms); timers.push(id); return id; };
}
run(host, doc, track(window.setTimeout.bind(window)),
track(window.setInterval.bind(window)));
}
function unmount() {
if (ac) ac.abort();
// المعرّفان يتشاركان فضاءً واحدًا في المتصفّح، فالإلغاء المزدوج آمن
timers.forEach(function (id) { window.clearTimeout(id); window.clearInterval(id); });
timers = [];
host.innerHTML = snapshot;
}
mount();
addEventListener('pt-lang', function () { unmount(); mount(); });
})();
# Bank Account Sign-up
**Role:** You are an Arabic-first UI designer and front-end engineer. Read the whole
specification before writing a single line, then follow it literally. If two requirements
conflict, favour usability over visual effect.
**Goal:** Bank Account Sign-up — IBAN verified with the full mod-97 checksum, not just its length
**Why this component matters:** A length check accepts a mistyped IBAN and the transfer bounces days later. Implement mod-97: move the first four characters to the end, map letters to numbers, and require a remainder of 1.
**Direction:** Genuine RTL — not a mirrored Latin layout. Use logical properties
(`margin-inline-start`, `padding-inline`, `inset-inline-start`, `text-align: start`),
never physical ones (`margin-left`, `left`). The layout must flip with `dir` on its own,
with no duplicated rules.
**Typography:** Cairo for Arabic, IBM Plex Sans for Latin. Arabic line-height must be
`0.18` higher than the Latin equivalent — dots, hamzas and maddas need more vertical room.
Arabic font-size runs `1.06×` the Latin size at the same optical weight.
**Numerals:** Western digits in both languages (`1,234.50`). Only the currency changes:
`ر.س` **after** the number in Arabic, `$` **before** it in English. Jordanian dinar
uses **three** decimal places, not two.
**Colors:** Dark mode — background `#0D142B` · surfaces `#211F54` · borders `#545C91` · text `#918FC2`.
Accent `#ADA9E8` must never exceed 8% of the screen area.
**Language:** Bilingual — every string carries both Arabic and English, and the layout
flips with `dir` automatically.
**States:** `default` · `hover` · `focus` · `active` · `disabled` · `loading` · `error`.
Do not design the resting state alone.
**Accessibility:** Contrast ratio at least `4.5:1`, complete keyboard navigation,
visible focus rings, and honour `prefers-reduced-motion`.
**Output:** Clean HTML and CSS in two separate files. No frameworks, no libraries,
no external dependencies.
**Important:** This component has no equivalent in any global library. Do not imitate a
Latin pattern and translate its labels — build it from Gulf market requirements directly.