You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2-ui/4-forms-controls/4-forms-submit/article.md
+23-22Lines changed: 23 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -1,42 +1,42 @@
1
-
# Forms: event and method submit
1
+
# فرمها: event و method submit
2
2
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 استفاده میشود.
4
4
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 آغاز شود. ما میتوانیم از آن استفاده کنیم که به صورت پویا فرمهای خودمان را ایجاد کنیم و به سرور بفرستیم.
6
6
7
-
Let's see more details of them.
7
+
بیایید جزئیات بیشتری از آنها ببینیم.
8
8
9
9
## Event: submit
10
10
11
-
There are two main ways to submit a form:
11
+
دو راه اصلی برای submit کردن یک فرم وجود دارد.
12
12
13
-
1.The first -- to click`<input type="submit">`or`<input type="image">`.
14
-
2.The second -- press `key:Enter`on an input field.
2.دومی -- فشار دادن `key:Enter`روی یک input field.
15
15
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()` را فراخوانی کند، آنگاه فرم به سمت سرور ارسال نخواهد شد.
17
17
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">` کلیک کنید.
21
21
22
-
Both actions show`alert`and the form is not sent anywhere due to `return false`:
22
+
هر دو فعالیت`alert`را نمایش میدهند و فرم به دلیل `return false` به هیچ جا فرستاده نمیشود:
23
23
24
24
```html autorun height=60 no-beautify
25
25
<formonsubmit="alert('submit!');return false">
26
-
First: Enter in the input field <inputtype="text"value="text"><br>
To submit a form to the server manually, we can call `form.submit()`.
48
+
برای اینکه یک فرم را به صورت دستی submit کنیم، میتوانیم `form.submit()` را فراخوانی کنیم.
49
49
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 خودش تمام پردازشهای مربوطه را انجام میدهد.
51
51
52
52
Sometimes that's used to manually create and send a form, like this:
53
+
گاهی اوقات معمول ایت است که یک فرم را با این روش ایجاد و ارسال کنند.
0 commit comments