Skip to content

Commit e76aa9e

Browse files
done article.md
1 parent b5a1d7e commit e76aa9e

1 file changed

Lines changed: 22 additions & 21 deletions

File tree

2-ui/4-forms-controls/4-forms-submit/article.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
# Forms: event و method submit
22

3-
The `submit` event triggers when the form is submitted, it is usually used to validate the form before sending it to the server or to abort the submission and process it in JavaScript.
3+
معمولا `submit` event زمانی فعال می‌شود که یک فرم submit می‌شود. معمولا برای اعتبارسنجی فرم قبل از اینکه به سمت سرور فرستاده شود یا لغو و پردازش آن در JavaScript استفاده می‌شود.
44

5-
The method `form.submit()` allows to initiate form sending from JavaScript. We can use it to dynamically create and send our own forms to server.
5+
متد `form.submit()` اجازه می‌دهد که فرستادن فرم از JavaScript آغاز شود. ما می‌توانیم از آن استفاده کنیم که به صورت پویا فرم‌های خودمان را ایجاد کنیم و به سرور بفرستیم.
66

7-
Let's see more details of them.
7+
بیایید جزئیات بیشتری از آن‌ها ببینیم.
88

99
## Event: submit
1010

11-
There are two main ways to submit a form:
11+
دو راه اصلی برای submit کردن یک فرم وجود دارد.
1212

13-
1. The first -- to click `<input type="submit">` or `<input type="image">`.
14-
2. The second -- press `key:Enter` on an input field.
13+
1. اولی -- کلیک کردن `<input type="submit">` یا `<input type="image">`.
14+
2. دومی -- فشار دادن `key:Enter` روی یک input field.
1515

16-
Both actions lead to `submit` event on the form. The handler can check the data, and if there are errors, show them and call `event.preventDefault()`, then the form won't be sent to the server.
16+
هر دو کار باعث `submit` event روی فرم می‌شوند. Handler می‌تواند داده را چک کند، و اگر خطاییی باشد، آن‌ها را نشان دهد و `event.preventDefault()` را فراخوانی کند، آنگاه فرم به سمت سرور ارسال نخواهد شد.
1717

18-
In the form below:
19-
1. Go into the text field and press `key:Enter`.
20-
2. Click `<input type="submit">`.
18+
در فرم زیر:
19+
1. به text field بعدی بروید و `key:Enter` را فشار دهید.
20+
2. روی `<input type="submit">` کلیک کنید.
2121

22-
Both actions show `alert` and the form is not sent anywhere due to `return false`:
22+
هر دو فعالیت `alert` را نمایش می‌دهند و فرم به دلیل `return false` به هیچ جا فرستاده نمی‌شود:
2323

2424
```html autorun height=60 no-beautify
2525
<form onsubmit="alert('submit!');return false">
26-
First: Enter in the input field <input type="text" value="text"><br>
27-
Second: Click "submit": <input type="submit" value="Submit">
26+
را بزنید enter ،input field در <input type="text" value="text"><br>
27+
را کلیک کنید "submit" دوم: <input type="submit" value="Submit">
2828
</form>
2929
```
3030

31-
````smart header="Relation between `submit` and `click`"
32-
When a form is sent using `key:Enter` on an input field, a `click` event triggers on the `<input type="submit">`.
31+
````smart header="`click` و `submit` ارتباط میان"
32+
.فعال می‌شود `<input type="submit">` روی `click` event فرستاده می‌شود یک `key:Enter` با input field وقتی که یک فرم در یک
3333

34-
That's rather funny, because there was no click at all.
34+
این نسبتا خنده‌دار است زیرا هیچ کلیکی اصلا وجود نداشته است.
3535

36-
Here's the demo:
36+
در اینجا نسخه‌ی نمایشی هست:
3737
```html autorun height=60
3838
<form onsubmit="return false">
39-
<input type="text" size="30" value="Focus here and press enter">
39+
<input type="text" size="30" value="اینجا فوکوس کنید">
4040
<input type="submit" value="Submit" *!*onclick="alert('click')"*/!*>
4141
</form>
4242
```
@@ -45,11 +45,12 @@ Here's the demo:
4545
4646
## Method: submit
4747
48-
To submit a form to the server manually, we can call `form.submit()`.
48+
برای اینکه یک فرم را به صورت دستی submit کنیم، می‌توانیم `form.submit()` را فراخوانی کنیم.
4949
50-
Then the `submit` event is not generated. It is assumed that if the programmer calls `form.submit()`, then the script already did all related processing.
50+
آنگاه `submit` event ایجاد نمی‌شود. تصور می‌شود که اگر برنامه‌نویس `form.submit()` را فراخونی کند، آنگاه script خودش تمام پردازش‌های مربوطه را انجام می‌دهد.
5151
5252
Sometimes that's used to manually create and send a form, like this:
53+
گاهی اوقات معمول ایت است که یک فرم را با این روش ایجاد و ارسال کنند.
5354
5455
```js run
5556
let form = document.createElement('form');
@@ -58,7 +59,7 @@ form.method = 'GET';
5859
5960
form.innerHTML = '<input name="q" value="test">';
6061
61-
// the form must be in the document to submit it
62+
// شود submit باشد تا document فرم باید در
6263
document.body.append(form);
6364
6465
form.submit();

0 commit comments

Comments
 (0)