עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

עזרה במחרוזות ב-JavaScript, בדיקת תקינות לאימייל

Featured Replies

פורסם

שלום :)

נתקעתי בשיעורי בית ב-JavaScript, כרגע על הנושא של מחרוזות.

אני צריך ליצור טופס ולבדוק שבכל השדות קיים ערך כלשהו, בנוסף יש לי בדיקות נוספות לאימייל שייקלט:

1. האימייל לא יכיל תווים לא חוקיים.

2. יכיל רק @ אחד.

3. נקודה לא יכולה להופיע בסמיכות ל-@ באף אחד משני צדיו.

4. נקודה חייבת להופיע, אבל לא במקום הראשון לפחות 2 תווים מהסוף.

אני תקוע רק בקטע של האימייל, משום מה זה לא עובד.

הנה מה שעשיתי עד עכשיו:

function vaild()
{
if (document.frm.fname.value=="")
{
alert ("First name is missing!");
document.frm.fname.focus();
return false;
}
if (document.frm.lname.value=="")
{
alert ("Last name is missing!");
document.frm.lname.focus();
return false;
}
if (document.frm.email.value=="")
{
alert ("E-mail is missing!");
document.frm.email.focus();
return false;
}
var wrongletters="!#$%^&*()+=|\/אבגדהוזחטיכלמנסעפצקרשתץףךם";
for (var i=0; i<wrongletters.length; i++)
{
var letter=wrongletters.charAt(i);
if (document.frm.email.indexOf(letter)!=-1)
{
alert ("You have a bad letter in the e-mail!");
document.frm.email.focus();
return false;
}
}
if (document.frm.email.split("@").length>2)
{
alert ("There is more then one shtrudel!");
document.frm.email.focus();
return false;
}
var shtrudel = document.frm.email.indexOf("@");
var dot = document.frm.email.indexOf(".");
if ((dot-shtrudel<=1)&&(dot-shtrudel>=-1))
{
alert ("The dot places near to the shtrudel!");
document.frm.email.focus();
return false;
}
if ((dot>0)&&(dot<document.frm.email.value-3))
alert("Your form is vaild!");
else
{
alert ("The dot is out of place or missing!");
document.frm.email.focus();
return false;
}
return true;
}

שום דבר מבדיקות התקינות של האימייל לא עובד..

פורסם

למה לא להשתמש בביטויים רגולרים ? המצאתי את זה

document.frm.email.match(/[a-zA-Z0-9]+@[a-zA-Z0-9]+(.[a-zA-Z0-9]+)*/)

אבל בטח יש יותר נורמלי באינטרנט.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.