.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Post New Web Links

Validate a certain number of input tags

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :WPF

My users will add text to be translated.
Inside the text we would like to allow a certain number of tags.
Most of them will be simple formatting but some can be extended to cover reserved words etc.

Now we would like to validate user input to ensure correct entries.

The assumption is to use HTML like formatting tags like: <b>, <br/>, <ul>, <li>, etc.
Even definitions could probably be covered by HTML if using something like: <code>, <cite>, <dfn>
This means it is fully possible to limit tags to valid HTML if that helps.

My initial guess is that Regex is faster since we will only allow a very limited number of tags.
But that validation soon becomes very complex, especially if we allow nested tags which is very much preferred and even necessary for <ul> lists.

Is there maybe a XHTML validator that might be possible to use?

I saw that TinyMCE has a similar input validation, but I am not able to detect how they actually process and apply it.
I still would prefer C# based solution over javascript.

View Complete Post

More Related Resource Links

Validate form input - Japanese


 I've searched for several hours and haven't come up with a reference - or even many discussions - of how to go about validating Japanese names, addresses, etc. When I lived in Japan websites, atm's etc. required such info to be entered with the roman alphabet but I've seen some websites that are allowing Kanji/Hiragana/Katakana. I haven't tested many of them for validation but one that I did test (after looking at the page source and discovering no client-side validation) allowed me to put this in the name field: J*=123*go^ Neat!

Any pointers/references? Thanks

Validate input has up to 2 decimal places

I need to validate hours put into a textbox.  I want to allow hours to be from 0-24 and allow up to 2 decimal places. so it has to accept not 2.225 or 25I put a range validator that check that the value is from 0-24 but it doesn't check that there are 2 decimal places or less.  how do I do that?

validate date/time span and alow only time input

Hi, I have 2 small questions: 1. How can I  make a filed for input only time without date? 2. I need to make a date/time validation in form like: if(time between begin_date_field  and end_date_field) is not in intersection (time between begin_date_field  and end_date_field) of any item in list) Can I make this validation only using VisualStudio2010 or is there a simpler way? ( I need this for small list for managing reservations of conference rooms )

How to Validate the Range of Number

$("#Thang").keypress(function (e) { if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { alert("Numeric is Required"); return false; } else { if($("#Thang").val() < 0 || $("#Thang").val() > 12 ){ alert("Range 1 - 12"); return false; } } });I try this code but it always  alert("Range 1 - 12"); in every input

Validate (Javascript) if input date is within this range...


I'd like to validate if the inputed date is within this range:

3 weeks before today's date to 3 weeks after today's date 

The following Javascript code checks if the date is within either today's date or 2 weeks before:

var dateSystem = (dateToday.getMonth() + 1) + dtCh + dateToday.getDate() + dtCh + dateToday.getFullYear();
            var prev = new Date();
            //past date 14 dates before today
            prev.setDate(prev.getDate() - 14);
            var pastDate = (prev.getMonth() + 1) + dtCh + (prev.getDate()) + dtCh + prev.getFullYear();
            var time1 = new Date(dateSystem).getTime();
            dtStr = month + dtCh + day + dtCh + year;
            var dateuser = new Date(dtStr);
            var time2 = dateuser.getTime();
            if (time1 - time2 <= 1209600000 && time2 <= time1) {
                return true;
            } else {
                alert("Vaccines/Services date must be within this date range: " + pastDate + " to " + dateSystem);
                return false
            return true


I'm not sure how to modify. I actually got the code above from these forums.

Help is much appreciated!

Phone Number Input Mask


I am fairly new to MVC.  I have a html helper textbox for phone number .  I am trying to apply a input mask of xxx-xxx-xxxx to th phone number html helper.  I even downloaded the Digital Bush Masked Input Plugin but it doesn't even work.  Can someone provide me some guidance on this matter.

Return of sequential number on user input



I'm new to this forum and just as new to asp :/

I have been tasked with what on the surface seems a simply problem. I need to provide users with a method of entering an order number and in return they are given the next sequential number (seeded from a resetable number). As each order number is entered and sequential number is returned and a list of all entries/outputs is maintained.

user 1 enters a number, returns 1

user 2 enters another number, returns 2

user 3 enters any number even a repeat of previous number, returns 3

A text file or similar is maintained with results




etc etc

I was going to do this with PHP but its no longer an option, I have IIS available so can be done via web form / asp / sql.

Would anyone be able to give me some pointers?

thanks very much

CLR Stored procedures : variable number of input paramters?


Hi there, I've just started looking into CLR stored procedures.

I'd like to create a stored procedure that takes in a variable number of parameters in the same way that sp_executesql does. 

I've tried creating the CLR proc as follows;

using System;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server; 

public class StoredProcedures 
  public static void PriceSum(params SqlString[] parms)


but this results in the following error;

Error	1	Column, parameter, or variable #1: Cannot find data type SqlString[].	StringFactory

so I'm guessing it can't be done. 

Is there a way to mimic sp_executesql ?

Restrict Number of Input Fields


How do I restrict the number of input fields in the form to match the size of the columns?

Table Columns Reads:

state: Type Char; Length: 2
zip: Type: char; Length: 5   
Phone: Type: char; Length: 12    
Fax: Type: char; Length: 12     
Email: Type: nvarchar; Length: 256 

BoundField Reads:

<asp:BoundField DataField="state" HeaderText="State:" SortExpression="state" />

<asp:BoundField DataField="zip" HeaderText="Zip Code:" SortExpression="zip" DataFormatString="{0:#####}" />

<asp:BoundField DataField="phone" HeaderText="Phone Number:" SortExpression="phone" DataFormatString="{0:(###) ###-####}" />

<asp:BoundField DataField="fax" HeaderText="Fax Number:" SortExpression="fax" DataFormatString="{0:(###) ###-####}" />

<asp:BoundField DataField="email" HeaderText="Email Address:" SortExpression="email" DataFormatString="&lt;a href=mailto:{0}&gt;{0}&lt;/a&gt"


Disable past date, showing URL in gridview and validate generated number



I've got 3 problems and I can't find the solution so that's why I'm here.
1. I've got a calander for adding a product to my shop. How can I make sure that you can't select a date in the past?
2. I have a gridview, and I have added a hyperlinkfield in access. When I'm filling up my gridview it doesn't show a link, it shows this:
example= www.Groezrock.be#http://www.Groezrock.be#
3. I've added a label and a textbox on my guestbook page. It says "Please fill in the number in the textbox -label that generates 4 random number- txtbox.
For filling up the textbox I use this code:

        Dim randObj As New Random
        lblVraag.Text = (randObj.Next(1001, 10000).ToString)

The problem is, when I fill in the number, it always gives me the validation error "Numbers don't match" which I added myself.

        If txtnumbers.Text = lblnumbers.Text Then
            lblFout.Text = "Numbers don't match."

End If

Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

JQuery Validate plugin to validate a ASP.NET Form

The first time I used the JQuery Validate plugin, it did not work at all, see JQuery Validate odd behaviour with the ASP.NET Script Manager for reason, but perseverance and stubbornness prevailed and I finally created my first JQuery validated ASP.NET Forms contact form.

Convert English to Arabic number without changing any regional settings in .net

Well, most applications that I worked with was multilingual that supports English UI and Arabic UI.

And one of the major issue that we have faced is displaying Arabic numbers without the need of changing the regional settings of the PC.

So the code below will help you to display Arabic number without changing any regional settings.

dynamically adding sql server columns based on number of files in fileuploader


I want to create a new table to sql database at runtime.  The column names would be "Name", "Date", "Event".  I would also like to have one more column name "Image" but the problem is that since the amount of images will vary, I want the application to count the amount of files in the Multiple fileuploader and then add a image column to the table for the respected amount of files. 

For example if i am uploading 3 files in the multiple fileuploader, the names should be "Name", "Date", "Event", "Image1", "image2", Image3"

I also would like that table name to be name dynamically from the textbox Name when the user enters the information.


I have the following code to make a new table, but I dont know how to name the fields at runtime like previously asked please help!!!


Dim objConn As New SqlConnection("Server=<servername>;uid=<userid>;pwd=<password>;database=master")


Embeb a variable number of videos


I need to provide some alternate content for my non-Flash users.

I have a directory of video files that is scanned using the DirectoryInfo() function, and I want to use the results to embed all files ending in ".mov" in QuickTime players on a web form.

How would you approach this? Right now I am using the count on the array of videos to determine how many times to repeat the embed code.  But this seems inelegant.

Is there a way to have a single QuickTime player.ascx control that gets duplicated according to the number of videos available for display?

Article commenting by line number


I'm wondering what's the best way to approach an online article system that allows users to comment by clicking on the line they are commenting about? Essentially the same way Adobe Acrobat works with comments where you can click anywhere and the text is saved for that location.

I'm assuming a mix of jQuery would be the crux of the interface. The system would need to save comments so that when another user logs in, they will also see the other comments but they can´t edit them - only add their own.

Any suggestions would be great.

The number of members in the conceptual type ... does not match with the number of members on the ob



I've added a scalar property to an entity and now ASP.NET Dynamic Data scaffolding throws this error:

The number of members in the conceptual type 'TrainingModel.Users' does not match with the number of members on the object side type 'TrainingModel.Users'. Make sure the number of members are the same.

This happens at the following line in global.asax:
model.RegisterContext(typeof(TrainingModel.TrainingEntities), new ContextConfiguration() { ScaffoldAllTables = true });

Please help!

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend