Using Vbscript Validation Tab to format/change a text type property.

I need to use the Vbscript Validation Tab to format/change a text type property that has a maximum length of 8 characters with the following format: #####-###

Could anyone help with some example script?

Thanks for any help!

Parents
  • Here is a script that runs a similar check. It should be easy for you to change it to suit your needs.

    'Script will check that Deadline is entered as a valid date in the format DD.MM in a text property
    Option Explicit
    If not IsNull( PropertyValue.TypedValue ) Then
    	Dim szPropVal : szPropVal = PropertyValue.GetValueAsUnlocalizedText
    	If len(szPropVal) > 5 then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)"
    	Elseif not IsNumeric(left(szPropVal,2)) Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Day must be 01 - 31"
    	Elseif left(szPropVal,1) > 3 Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "First character must be 0, 1, 2 or 3"
    	Elseif left(szPropVal,2) > 31 Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Day must be 01 - 31"
    	Elseif mid(szPropVal,3,1) <> "." Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Third character must be '.'"
    	Elseif not IsNumeric(mid(szPropVal,4,2)) Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Month must be 01 - 12"
    	Elseif mid(szPropVal,4,1) > 1 Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Fourth character must be 0 or 1"
    	Elseif mid(szPropVal,4,2) > 12 Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Month must be 01 - 12"
    	End if
    End if

Reply
  • Here is a script that runs a similar check. It should be easy for you to change it to suit your needs.

    'Script will check that Deadline is entered as a valid date in the format DD.MM in a text property
    Option Explicit
    If not IsNull( PropertyValue.TypedValue ) Then
    	Dim szPropVal : szPropVal = PropertyValue.GetValueAsUnlocalizedText
    	If len(szPropVal) > 5 then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)"
    	Elseif not IsNumeric(left(szPropVal,2)) Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Day must be 01 - 31"
    	Elseif left(szPropVal,1) > 3 Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "First character must be 0, 1, 2 or 3"
    	Elseif left(szPropVal,2) > 31 Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Day must be 01 - 31"
    	Elseif mid(szPropVal,3,1) <> "." Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Third character must be '.'"
    	Elseif not IsNumeric(mid(szPropVal,4,2)) Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Month must be 01 - 12"
    	Elseif mid(szPropVal,4,1) > 1 Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Fourth character must be 0 or 1"
    	Elseif mid(szPropVal,4,2) > 12 Then
    		err.raise MFScriptCancel, "Deadline must be entered as 5 characters in the format DD.MM (day.month)" & VbCrLF & "Month must be 01 - 12"
    	End if
    End if

Children
No Data