הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   גאווה סקריפט | לא מוצא את הבעיה (https://hosts.co.il/forums/showthread.php?t=75794)

Megnum 21-06-09 11:04

גאווה סקריפט | לא מוצא את הבעיה
 
היי, רשמתי את הקוד הבא והוא אמור לבצע ככה: אם הערך ריק אז המסגרת הופכת לאדום ואם הערך גדול מ2 הוא אמור לצבוע לירוק ומשום מה זה פשוט לא עובד נכון. אם אני מכניס ערך כלשהו אפילו שהוא קטן מ 2 הוא מסמן בירוק ואם הערך ריק הוא לא מסמן באדום כמו שהוא אמור להיות ובFF הוא בכלל לא עובד הקוד הזה.

הינה הקוד:
HTML קוד:


<html dir="rtl">
<head>
<title>s</title>
<script  language="javascript">
function check_error(id) {

if (document.contact.id.length < 2) {
document.getElementById(id).style.border="1px dotted #58B52D";
document.getElementById(id).style.background="url(accept.png) left no-repeat 10px;";
}

else {
document.getElementById(id).style.border="1px dotted red";
}

}


</script>

<style>
form.contact {width: 550px; background: url(icon_contact.gif) left top no-repeat 60px;}
input.type {border: 1px  dotted black; margin-top: 6px; color: #808080; width: 310px; font-size: 11px;}
input.submit {border:  0px; font-size:11px; color: #FF5900; width: 80px; text-align: right; font-weight: bold; background: none; font-wieght: bold; font-size: 11px;}
textarea.content {margin-top: 6px; font-size: 11px;  border: 1px  dotted #BFBFBF; font-family: "ariel", sans-serif; color: #808080; background: url(contact.gif) top repeat-x;}
h3 { margin:  1px 1px 1px 1px; font-family:ariel, sans-serif ;}
</style>


</head>
<body>
<form method="post" action="" name="contact" class="contact" onload="void();">
<table>
</table>
<h3>פנייה ישירה בטלפון: 0546280268</h2>
<input type="text" class="type" name="first_name"  value='*שם פרטי' onclick="this.value=''" onkeypress="check_error('first_name');" /><br />
<input type="text" class="type" name="last_name"  value='*שם משפחה' onclick="this.value=''" onkeypress="check_error('last_name');" /><br />
<input type="text" class="type" name="email"  value='*דואר אלקטרוני' onclick="this.value=''" onkeypress="check_error('email');"/><br />
<input type="text" class="type" name="phone"  value='טלפון' onclick="this.value=''" onkeypress="check_error('phone');" /><br />
<input type="text" class="type" name="pelephone"  value='פלאפון' onclick="this.value=''" onkeypress="check_error('pelephone');" /><br />
<input type="text" class="type" name="fax"  value='פקס' onclick="this.value=''" onkeypress="check_error('fax');" /><br />
<textarea name="content" class="content" onkeyup="check_error('content');" rows="10" cols="70">רשום כאן את תוכן הפנייה</textarea>
</form>











</body>
</html>


תודה לעוזרים!

mlnn 21-06-09 11:22

תבדוק ככה
קוד:

document.getElementById(id).value.length < 2
ואיך אתה מצפה לגשת לזה בעזרת id אם אתה לא כותב את הid בInput?

עריכה:
גם אתה בודק בכלל שאם זה קטן מ2 אז שיצבע לירוק... לא אדום..

Megnum 21-06-09 12:05

תודה רבה אפילו לא שמתי לב לזה.


כל הזמנים הם GMT +2. הזמן כעת הוא 16:10.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ