custom validation client side איך לעשות את זה

krambo1

New member
custom validation client side איך לעשות את זה

היי

איך הייתם עושים את זה בדרך הכי מהירה?
יש לי דף שמחולק לכמה טבלאות. בכל טבלה יש שורה עם 2 TEXTBOXES וכל טבלה השם מתחיל משהו כמו
txtPropRateFrom txtPropRateTo
txtPropExchangeFrom txtPropExchangeTo

בטבלה השניה אותו עיקרון שtxtFeat זה איך שהשם מתחיל לקונטרול של הטבלה
txtFeatRateFrom txFeatRateTo
txtFeatExchangeFrom txtFeatExchangeTo

עכשיו יש לי יותר מ-30 שורות כאלה.
אני צריכה לעשות כמה בדיקות כמו שה-FROM תמיד יהיה קטן מה -TO
שאפשר בטבלה הראשונה להכניס רק מספרים ובשניה גם נקודה.
שאי אפשר למשל בטלבה הראשונה לרשום מספרים שהם לא בתווך של 0-100

אני רוצה לעשות את הכל פעם אחד באיזה פונקציה CUSTOM ובלחיצה על כפתור לראות ליד כל שורה את הבעיות -הודעה שגיאה. אני לא רוצה להוסיף כמה ומכה VALIDATORS. רק אחד.
אני שוברת את הראש עם איך לעשות את זה. איך הייתם עושים את זה ואשמח אם יש לכם דוגמא. אמרו לי להשתמש ב JAVASCRIPT וב- SENDER. לא מצליחה.

תודה
 

Royi Namir

New member
דך אגב עשיתי פלאגין (לטעמי יותר טוב)

הוא בשלבי פיתוח אבל הרבה יותר דינמי ועם יכולות מאשר JQ VALIDATION PLUG
 

HackPoint

New member
זרוק שיתוף לHUB נעשה FORK ונראה אולי נוכל להיות contributers

 

Royi Namir

New member
בכיף , רק אני צריך מוזה לזה . דווקא יהיה נחמד להעלות ל GIT

מרוב שיש שם כל כך הרבה אופציות - תריך לעשות הרבה JSBINS בשביל דוגמאות.
&nbsp
אבל אני יעשה את זה היום או מחר.מקסימום אני אשלח לך ונעשה ביחד
 

krambo1

New member
תודה לכולם. אני צריכה לעשות את זה בצד השרת

מסתבר שזה לא טוב בצד ה CLIENT. ניסיתי לעשות משהו אבל לא קורה כלום שלוחצים על הכפתור. אני רוצה לבדוק שאם המשתמש הזין שדה מ- ועד- לבדוק שהשדה מ-קטן ולא יותר גדול מהשדה עד. אם המשתמש הזין רק שדה עד או רק שדה מ- לא צריכה לבדוק כלום.
ואיך בודקים שהזינו DECIMAL עם נקודה אחד בלבד?

תודה רבה

Private Sub AddCustomValidation(ByVal container As Control) Dim custom As CustomValidator
Dim vldtxt As TextBox
For Each ctrl In container.Controls If TypeOf ctrl Is TextBox Then vldtxt = CType(ctrl, TextBox) custom = New CustomValidator custom.Text = "To field must be bigger than from field" custom.ControlToValidate = vldtxt.ID AddHandler custom.ServerValidate, AddressOf CustomValidation Me.form1.Controls.Add(custom) Else AddCustomValidation(ctrl) End If NextEnd SubProtected Sub CustomValidation(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Dim vldtxt As TextBox Dim othertxt As TextBox Dim othertxtid As String Dim txtid As String Dim lower As String Dim higher As String For Each ctrl As Control In tbl1.Controls vldtxt = TryCast(ctrl, TextBox) othertxt = TryCast(ctrl, TextBox) If vldtxt IsNot Nothing Then txtid = ctrl.ID ''check if to is not empty and if not empty then check that that to value is higher ''than from value If ((txtid.ToLower.EndsWith("to")) And (vldtxt.Text <> "")) Then higher = (vldtxt.Text) othertxtid = vldtxt.ID.Replace("To", "From") othertxt = Page.FindControl(othertxtid) othertxt.ID = othertxtid lower = (othertxt.Text) If lower = String.Empty Or higher = String.Empty Then args.IsValid = True End If If Int32.Parse(lower) >= Int32.Parse(higher) Then args.IsValid = False End If Else args.IsValid = True End If End If NextEnd Sub
 
למעלה