English 中文(简体)
表格验证客户方和服务器方
原标题:Form validation client side and server side

应同时对html表格进行验证,同时对双方都进行reg。

客户方面:向用户发出信息而无需询问服务器

服务器方面:确认所有物品都属于罚款,在小孩残疾或试图冲破表格的人情况下安全检查。

我的问题是:我通常看到服务器的侧面reg和客户方reg之间出现一些不相同的错误。

C#中的I m, 您是否认为Reex应当备份,服务器应当把自己的reg放在客户一边?

我想避免:

C# -> public const string AlphanumericField = @"[^A-Za-z0-9_]";
JS -> var alpahField = "[^A-Za-z_-]";

I want to avoid both declaration for the same thing.

问题回答

For the regualtare expression I always make use of RegularExpressionValidator available in the asp.net

查询:,以更详细地介绍正式表述有效者的情况。

If possible in your app, you could do an AJAX call for your client side validation, which would allow you to have that RegEx in one place, and easily testable. You may take a very minor performance hit going to the server everytime you need to check this, but the maintainability is worth it in many cases.

你们可以要求C#使用登记客户笔记栏块宣布这种 variable印变量。

Dim cstext2 As New StringBuilder()
            cstext2.Append("<script type=""text/javascript"">")
            cstext2.Append("var alpahField = "" + AlphanumericField  +"";")
            cstext2.Append("script>")
            RegisterClientScriptBlock(csname2, cstext2.ToString())




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签