الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

طلب صغير في التحكم بالبيانات المدخله على حقل

مغلق
بدأه mhmdmhmd في 9 يناير 2008 · 1 رد · 659 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

لو سمحتم هل من مساعده في موضوع صغير

أريد أن أمنع كتابه أي حرف عربي في حقل وفقط أكتب بالانجليزي داخله

والعكس أيضا حقل أكتب فيه حروف عربيه فقط

مع العلم انه مسموح الفواصل بين الكلمات

هل يوجد شي جاهز في Validation مثلا ؟ أو انها برمجه لازم تكون ؟

الرجاء الرد والمساعده وبارك الله فيكم

#2

هلا اخي هذا كود يستخدم من أجل التحقق فيما اذا كان المدخل باللغة العربية أو الاجنبية أو ارقام فقط اذا كان هناك اي مشكلة فيرجى اعلامي لأني كتبته لم أجرب الكود بشكل كامل

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default"
	 Culture="ar-SY" UICulture="ar" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head runat="server">
	 <title>Untitled Page</title>
	 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

	 <script language="javascript">

 function ValidateArabicInput(txtID) {
 var charout = "";
 var code = "";

 for(var i = 0; i < 
 document.getElementById(txtID).value.length;i++)
 {
	 code = document.getElementById(txtID).value.charCodeAt(i);
	 if ((code <1575 || code > 1610) && (code != 32)){
		 alert('please enter only arabic charater');
		 setColor(document.getElementById(txtID));   
		 document.getElementById(txtID).value=""
		 document.getElementById(txtID).focus();
		 return false
	 }
 }
 }// end function

 function ValidateEngilshInput(txtID) {
 var charout = "";
 var code = "";
 for(var i = 0; i < 
 document.getElementById(txtID).value.length;i++)
 {
	 code = document.getElementById(txtID).value.charCodeAt(i);
	 if ((code <65 || code > 122) && (code != 32)){
		 alert('please enter only english charater');
		 setColor(document.getElementById(txtID));   
		 document.getElementById(txtID).value=""
		 document.getElementById(txtID).focus();
		 return false
	 }
 }
 }// end function

 function ValidateDigitInput(txtID) {
 var charout = "";
 var code = "";

 for(var i = 0; i < 
 document.getElementById(txtID).value.length;i++)
 {
	 code = document.getElementById(txtID).value.charCodeAt(i);
	 if ((code <48 || code > 57) && (code != 32)){
		 alert('please enter only digital charater');
		 setColor(document.getElementById(txtID));   
		 document.getElementById(txtID).value=""
		 document.getElementById(txtID).focus();
		 return false
	 }
 }
 }// end function
 function setColor(elem){
 elem.style.backgroundColor='rgb(255,0,0)';
 }
 function clearColor(elem) {
 document.getElementById('txtarab').style.backgroundColor='rgb(255,255,255)';
 document.getElementById('txteng').style.backgroundColor='rgb(255,255,255)';
 document.getElementById('txtdigit').style.backgroundColor='rgb(255,255,255)';
 }

	 </script>

 </head>
 <body style="font: caption">
	 <form id="form1" runat="server">
		 <div>
			  </div>
		 <table>
			 <tr>
				 <td>
					 <asp:Label ID="Label1" runat="server" Text="only arabic"></asp:Label></td>
				 <td>
					 <asp:TextBox ID="txtarab" runat="server"></asp:TextBox></td>
				 <td style="width: 17px">
					 <asp:Button ID="Button1" runat="server" Text="valid" OnClientClick="java script:return ValidateArabicInput('txtarab');" /></td>
			 </tr>
			 <tr>
				 <td>
					 <asp:Label ID="Label2" runat="server" Text="only english"></asp:Label></td>
				 <td>
					 <asp:TextBox ID="txteng" runat="server"></asp:TextBox></td>
				 <td style="width: 17px">
					 <asp:Button ID="Button2" runat="server" Text="valid" OnClientClick="java script:return ValidateEngilshInput('txteng');" /></td>
			 </tr>
			 <tr>
				 <td>
					 <asp:Label ID="Label3" runat="server" Text="only digit"></asp:Label></td>
				 <td>
					 <asp:TextBox ID="txtdigit" runat="server"></asp:TextBox></td>
				 <td style="width: 17px">
					 <asp:Button ID="Button3" runat="server" Text="valid" OnClientClick="java script:return ValidateDigitInput('txtdigit');" /></td>
			 </tr>
			 <tr>
				 <td>
				 </td>
				 <td>
				 </td>
				 <td style="width: 17px">
				 </td>
			 </tr>
		 </table>
	 </form>
 </body>
 </html>

والبرنامج موجود بالمرفق

validition.zip

تم تعديل هذه المشاركة بواسطة محمد سماقية في 10 يناير 2008 في 19:51

1

-----------------------------------------------------------------------------------------------------------------------------





 

ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــ

Mohammad Sonaiea
 

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…