Validation Expression
Last Post 10/10/2006 10:49 AM by David Stacey. 3 Replies.
Author Messages
David Stacey
Nuker
Nuker
Posts:14


--
09/28/2006 11:31 AM  

How can i use a Validation Expression o ensure that a user does not select a certain value from a list?

For example, If i had a list and one of the items was "Select an Option"  how do ensure that this is not a valid selectable option?

Many thanks

David Stacey

Lee Sykes
DNN Creative Staff
Nuke Master VI
Nuke Master VI
Posts:4945


--
09/29/2006 3:14 AM  
Hello,

I posted info here regarding validation expressions:
http://www.dnncreative.com/Forum/ta...fault.aspx

I haven't tried this, but the first thing I would do is when you create your list in the host menu - for the 'Select an Option' give it a numerical value - ie. 1

Then in the validation expression get it to check for alphanumeric values, if it sees a number it will not allow the form to be processed.

- This is a guess, I wanted to give you a starting point as I'm going away for a few days.

If you find the solution, can you post it here for everyone to read, thanks,
Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/DNNCreative

Lee Sykes's Facebook Profile
David Stacey
Nuker
Nuker
Posts:14


--
10/01/2006 8:35 AM  
Hello.
I have found a solution, here it is:

Create the list in he usual way, I created one for hair colour

Entry Name = Hair (** Avoid spaces **)

Entry Text Entry Value
----------------------------------------
Select hair colour 0
Black 1
Brown 2

Continue as required

Next edit the Profile.ascx.resx file in the usual way.

Next add the list to your form in the 'Manage Profile Properties' window, using the following settings:

Default Value = 0
(Or which ever value corresponds to the entry you want as default)

ValidationExpresion = [^0]
(Or which ever value corresponds to the entry you want as an invalid selection)
(** IMPORTANT - Include the square brackets **)

Note:
I have not tested this to use double figures, ie >=10
if you find this does not work in that case an alternative would be to use text for the 'Entry Value' for all except the entry you want to be an invalid selection, for this entry use a numerical value for the 'Entry Value' Then use:

Validation Expression = \D
** Uppercase 'D' is important - a lowercase 'd' will have the opposite effect and cause only numecal values to be valid **

Hope This Helps
David Stacey
David Stacey
Nuker
Nuker
Posts:14


--
10/10/2006 10:49 AM  
Hi
I have discovered another solution - which i think is better than the above as i have discovered it fails for numbers =>10

Here is the alternative:
create the list and for the item you want as unselectable in the "Entry Value" field enter the text "Invalid"

i.e:
Entry Name = Hair
Entry Text = Select Your Hair Colour
Entry Value = Invalid

For the remainder of the list i used numerical values

and the validation expression:

^\d+$

This expression validates a numerical value =>0

I used this in long lists and had no problem

Dave Stacey


---