كنترل ورودي

melina

کاربر تازه وارد
تاریخ عضویت
23 مارس 2003
نوشته‌ها
39
لایک‌ها
0
چطور میتوانم توی فرم ASP ورودی های text box ها رو کنترل کنم.
مثلا چک کنم که حتما حروف وارد بشه و غير از حرف نشه وارد کرد يا اينکه فقط عدد وارد شه.
ممنون ميشم اگه کمکم کنيد
 

knowhow

مدیران قدیمی
تاریخ عضویت
25 دسامبر 2002
نوشته‌ها
3,479
لایک‌ها
21
ببين بهترين روش استفاده از جاوا اسكريپت است.

يك جستجو در گوگل بكن. ببين اگه گيرت نيومد ، من برات پيدا مي كنم.
 

koorosh

Registered User
تاریخ عضویت
12 دسامبر 2002
نوشته‌ها
1,525
لایک‌ها
10
سن
38
محل سکونت
Iran - Tehran
اين رو ببين
<a href='http://javascript.internet.com/forms/block-key-press.html' target='_blank'>http://javascript.internet.com/forms/block...-key-press.html</a>

. . .
 

saeedsmk

مدیر بازنشسته
تاریخ عضویت
6 سپتامبر 2003
نوشته‌ها
1,518
لایک‌ها
4
با سلام اين كد چند تا تكس باكس رو چك مي كنه
[code:1]

&nbsp; &nbsp;&#60;script Language=&#34;JavaScript&#34; Type=&#34;text/javascript&#34;&#62;&#60;!--

function check&#40;theForm&#41;

&#123;



&nbsp;if &#40;theForm.name.value == &#34;&#34;&#41;

&nbsp;&#123;

&nbsp; &nbsp;alert&#40;&#34;Please enter a value for the &#34;name&#34; field.&#34;&#41;;

&nbsp; &nbsp;theForm.name.focus&#40;&#41;;

&nbsp; &nbsp;return &#40;false&#41;;

&nbsp;&#125;



&nbsp;if &#40;theForm.lname.value == &#34;&#34;&#41;

&nbsp;&#123;

&nbsp; &nbsp;alert&#40;&#34;Please enter a value for the &#34;lname&#34; field.&#34;&#41;;

&nbsp; &nbsp;theForm.lname.focus&#40;&#41;;

&nbsp; &nbsp;return &#40;false&#41;;

&nbsp;&#125;



&nbsp;if &#40;theForm.email.value == &#34;&#34;&#41;

&nbsp;&#123;

&nbsp; &nbsp;alert&#40;&#34;Please enter a value for the &#34;email&#34; field.&#34;&#41;;

&nbsp; &nbsp;theForm.email.focus&#40;&#41;;

&nbsp; &nbsp;return &#40;false&#41;;

&nbsp;&#125;



&nbsp;var checkOK = &#34;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸ&Agrave;&Aacute;&Acirc;&Atilde;&Auml;&Aring;&AElig;&Ccedil;&Egrave;&Eacute;&Ecirc;

&Euml;&Igrave;&Iacute;&Icirc;&Iuml;&ETH;&Ntilde;&Ograve;&Oacute;&Ocirc;&Otilde;&Ouml;&Oslash;&Ugrave;&Uacute;&Ucirc;&Uuml;&Yacute;&THORN;&szlig;à&aacute;â&atilde;&auml;&aring;

&aelig;çèéêë&igrave;&iacute;îï&eth;&ntilde;&ograve;&oacute;ô&otilde;&ouml;&oslash;ù&uacute;ûü&yacute;&thorn;&yuml;[email protected]&#34;;

&nbsp;var checkmail=&#34;&#34;

&nbsp;var checkStr = theForm.email.value;

&nbsp;var allValid = true;

&nbsp;var validGroups = true;

&nbsp;for &#40;i = 0; &nbsp;i &#60; checkStr.length; &nbsp;i++&#41;

&nbsp;&#123;

&nbsp; &nbsp;ch = checkStr.charAt&#40;i&#41;;

&nbsp; &nbsp;for &#40;j = 0; &nbsp;j &#60; checkOK.length; &nbsp;j++&#41;

&nbsp; &nbsp; &nbsp;if &#40;ch == checkOK.charAt&#40;j&#41;&#41;

&nbsp; &nbsp; &nbsp; &nbsp;break;

&nbsp; &nbsp;for &#40;j = 0; &nbsp;j &#60; checkOK.length; &nbsp;j++&#41;



&nbsp; &nbsp;if &#40;j == checkOK.length&#41;

&nbsp; &nbsp;&#123;

&nbsp; &nbsp; &nbsp;allValid = false;

&nbsp; &nbsp; &nbsp;break;

&nbsp; &nbsp;&#125;

&nbsp;&#125;

allValid = false;

checkmail=&#34;@&#34;;

&nbsp;for &#40;i = 0; &nbsp;i &#60; checkStr.length; &nbsp;i++&#41;

&nbsp;&#123;

&nbsp; &nbsp;ch = checkStr.charAt&#40;i&#41;;

&nbsp; &nbsp; &nbsp;if &#40;ch == checkmail&#41;&#123;

&nbsp; &nbsp; &nbsp; allValid = true;

&nbsp; &nbsp; &nbsp; &nbsp;break;&#125;

&nbsp;&#125;

allValid = false;

checkmail=&#34;.&#34;;

&nbsp;for &#40;i = 0; &nbsp;i &#60; checkStr.length; &nbsp;i++&#41;

&nbsp;&#123;

&nbsp; &nbsp;ch = checkStr.charAt&#40;i&#41;;

&nbsp; &nbsp; &nbsp;if &#40;ch == checkmail&#41;

if &#40;i!=checkStr.length-1&#41;&#123; &nbsp;

&nbsp; &nbsp; &nbsp; allValid = true;

&nbsp; &nbsp; &nbsp; &nbsp;break;&#125;

&nbsp;&#125;

checkmail=&#34;,&#34;;

&nbsp;for &#40;i = 0; &nbsp;i &#60; checkStr.length; &nbsp;i++&#41;

&nbsp;&#123;

&nbsp; &nbsp;ch = checkStr.charAt&#40;i&#41;;

&nbsp; &nbsp; &nbsp;if &#40;ch == checkmail&#41;

if &#40;i!=checkStr.length-1&#41;&#123; &nbsp;

&nbsp; &nbsp; &nbsp; allValid = false;

&nbsp; &nbsp; &nbsp; &nbsp;break;&#125;

&nbsp;&#125;





&nbsp;if &#40;!allValid&#41;

&nbsp;&#123;

&nbsp; &nbsp;alert&#40;&#34;Please enter email like this &#34;[email protected]&#34;.&#34;&#41;;

&nbsp; &nbsp;theForm.email.focus&#40;&#41;;

&nbsp; &nbsp;return &#40;false&#41;;

&nbsp;&#125;



&nbsp;var checkOK = &#34;0123456789-&#34;;

&nbsp;var checkStr = theForm.tel.value;

&nbsp;var allValid = true;

&nbsp;var validGroups = true;

&nbsp;var decPoints = 0;

&nbsp;var allNum = &#34;&#34;;

&nbsp;for &#40;i = 0; &nbsp;i &#60; checkStr.length; &nbsp;i++&#41;

&nbsp;&#123;

&nbsp; &nbsp;ch = checkStr.charAt&#40;i&#41;;

&nbsp; &nbsp;for &#40;j = 0; &nbsp;j &#60; checkOK.length; &nbsp;j++&#41;

&nbsp; &nbsp; &nbsp;if &#40;ch == checkOK.charAt&#40;j&#41;&#41;

&nbsp; &nbsp; &nbsp; &nbsp;break;

&nbsp; &nbsp;if &#40;j == checkOK.length&#41;

&nbsp; &nbsp;&#123;

&nbsp; &nbsp; &nbsp;allValid = false;

&nbsp; &nbsp; &nbsp;break;

&nbsp; &nbsp;&#125;

&nbsp; &nbsp;if &#40;ch == &#34;,&#34;&#41;

&nbsp; &nbsp;&#123;

&nbsp; &nbsp; &nbsp;allNum += &#34;.&#34;;

&nbsp; &nbsp; &nbsp;decPoints++;

&nbsp; &nbsp;&#125;

&nbsp; &nbsp;else

&nbsp; &nbsp; &nbsp;allNum += ch;

&nbsp;&#125;

&nbsp;if &#40;!allValid&#41;

&nbsp;&#123;

&nbsp; &nbsp;alert&#40;&#34;Please enter only digit characters in the &#34;tel&#34; field.&#34;&#41;;

&nbsp; &nbsp;theForm.tel.focus&#40;&#41;;

&nbsp; &nbsp;return &#40;false&#41;;

&nbsp;&#125;



&nbsp;if &#40;decPoints &#62; 1 || !validGroups&#41;

&nbsp;&#123;

&nbsp; &nbsp;alert&#40;&#34;Please enter a valid number in the &#34;tel&#34; field.&#34;&#41;;

&nbsp; &nbsp;theForm.tel.focus&#40;&#41;;

&nbsp; &nbsp;return &#40;false&#41;;

&nbsp;&#125;





&nbsp;return &#40;true&#41;;

&#125;

//--&#62;&#60;/script&#62;





nobody[/code:1]
 
بالا