I have two currency fields, Tuition_Math__c, Tuition_Math_Max__c.
Need a validation on Tuition_Math_Max__c field.
if a value is entered in Tuition_Math_Max__c, and Tuition_Math__c is blank then user should be prompted a message that Tuition_Math__c cannot be blank.
and if Tuition_Math__c is not blank, then Tuition_Math_Max__c should be greater than Tuition_Math__c.
below validation rule is not working.
'AND (NOT(ISBLANK(Tuition_Math__c)), Tuition_Math_Max__c > Tuition_Math__c)'
2 validation rules might be best to show different error messages. If you really want you can combine them in one.
if a value is entered in Tuition_Math_Max__c, and Tuition_Math__c is
blank
!ISBLANK(Tuition_Math_Max__c) && ISBLANK(Tuition_Math__c)
If it appears to now work ok pay attention to bottom of the editor, make sure "treat blanks as blanks" is checked.
if Tuition_Math__c is not blank, then Tuition_Math_Max__c should be
greater than Tuition_Math__c
!ISBLANK(Tuition_Math__c) && Tuition_Math_Max__c <= Tuition_Math__c
Related
How can I make a expression to compare multiple textbox and get a value?
I have this Expression: =IIF(fields!productformat.Value="Fresh - Skin OFF Loin", "OFF", "") but I need first to check other textboxes and columns if matches then gives the result.
Imagine:
I have 2 column "Specie" and "Skin" and 2 textboxes (txtSpecie and txtSkin), so first it most check if the txtSpecie is the same with the "Specie" column if yes then check what's the value of the "Skin" if the Skin value = "Skin Off" convert to "Off" if "Skin On" convert to "On"
I've made a question previously about this but I didn't express really what I wanted. I have a textbox that requires the user to write a Date in it. Then he can press a button and generate a report based on the entries on some other textboxes. It is really important that the date in the generated report is in this format "dd/MM/yy".
I use this code :
Dim a as String
a = Format(Textbox1.text, "dd/MM/yy")
Everything is working fine except when the user types a date in this format "dd.MM.yy" e.g 15.05.15 . When this happens, the date in the generated report is always "30/12/99". Can some1 help me understand why this is happening ?
EDIT: Regarding the Duplicate Question. In the previous question I asked how I can extract characters from a textbox and form a date in the format I want. This question is about a specific problem that happens when a specific type of format is used in the textbox (dd.MM.yy) that prints a specific date always (30/12/99).
30/12/1899 is the Date equivalent of 0, this is what you get when you try to convert a String which is not in a correct date format to a Date.
To verify this, type any old rubbish into your text box and you will get 30/12/99 as output.
Regarding using a DateTimePicker control, see my answer to your other question here
you can chose which keys you allow in the textbox.
for example as follows:
'1 form with:
' 1 textbox : name=Text1
Option Explicit
Private Sub Text1_KeyPress(KeyAscii As Integer)
' Caption = CStr(KeyAscii)
KeyAscii = DateOnly(KeyAscii)
End Sub
Private Function DateOnly(intKey As Integer) As Integer
Dim intResult As Integer
intResult = intKey
Select Case intKey
Case vbKeyBack 'allow backspace
Case vbKey0 To vbKey9 'allow numbers
Case 45 'allow -
' Case 46 'change . into /
' intResult = 47
Case 47 'allow /
Case Else 'dont allow anything else
intResult = 0
End Select
DateOnly = intResult
End Function
this just limits which keys the user can enter, you will still have to pay attention to other invalid inputs
[EDIT]
I added Case 45 to the code above.
In the select case you specify what happens to each key input:
you allow the key unaltered by specifying nothing, as i did with the / (ascii value 47)
you can change the key to another key, as i did with the . (ascii value 46)
you can reject the key input by setting it to 0, as i did with all other keys (case else)
You can find out which ascii value a specific key has by uncommenting the first line in Text1_KeyPress so the ascii value will show in the form caption
The IsDate Function is also useful. This will check if the date entered is valid, and return True if it is.
IsDate ("21/05/2015") 'returns 'True'
IsDate ("21.05.2015") 'returns 'False'
You could use the Replace function to change "." to "/"
mydate = Replace("21.05.2015", ".", "/") ' gives "21/05/2015"
I have connected the sql database to my vb project and the last feature I need is to validate the user input. Two of the textboxes needs to be validated when adding a new record.
txtName is the first textbox that consists of the following format: BCO103/T1/01 . 'BCO' will always stays the same, however the rest needs to be input by the user. Letters and numbers needs to stay in exact the same place.
txtModuleID is the second textbox that needs to be validated. The data for this field looks like this: BCO120 . Yet again, BCO will always stay the same, however the 3-digit number will change.
Im sure you can use substrings for this
for example:
If txtModuleID.Text.Substring(0,2) = "BCO" And txtModuleID.Text.Substring... etc Then 'add other conditionals
blnValidated = True
Else
blnValidated = False
End If
If txtModuleID.Text.Trim.ToUpper().SubString(0,2).equals("BCO") and len(txtModuleID.Text.Trim) = 6 Then
If txtModuleID.Text.Trim.SubString(3,5).isNumeric() Then
//valid input
Else
//message prompt that last 3 digits of the input is not numeric
End If
Else
//message prompt that input has invalid format and that input must start with BCO
End IF
Substring (0, 2) means from 0 until 2... getting the sub string of the input with letters in index 0, 1 and 2. The rest follows.
As for the first input, please do expound. I didn't quite catch how you want it to be validated.
I have "Content type" called Banner, it has two date fields:
ad_start
and
ad_stop
Both set to be date and time format. With ad_start default to "now" and ad_stop default set to "+7 days".
I then have a view "Frontpage Floor Banner" in which I want to have a filter in order to filter out all banners with
ad_start => "now"
and
ab_stop <= "now"
Under Configure filter criterion: Content: Start (field_ad_start), Operator has following possible options to choose from:
Is equal to
Is not equal to
Contains
Contains any word
Contains all words
Starts with
Does not start with
Ends with
Does not end with
Does not contain
Length is shorter than
Length is longer than
Regular expression
Is empty (NULL)
Is not empty (NOT NULL)
However I cant understand which Operator I can use to achieve this...
This is on 8.0.0-beta9.
Make sure to use the latest version of Drupal 8, because for a while there was no Datetime field filter for views, and it would have treated it like an integer rather than a date. In Drupal 8.0.5 (the latest as of this writing) the available operators for a core Datetime field are;
Is less than
Is less than or equal to
Is equal to
Is not equal to
Is greater than or equal to
Is greater than
Is between
Is not between
Regular expression
Is empty (NULL)
Is not empty (NOT NULL)
So for ad_start you would choose 'Is greater than or equal to' and for "Value type" choose 'An offset from the current time such as "+1 day" or "-2 hours -30 minutes"', then enter:
now
For ad_stop choose 'Is less than or equal to' and for "Value type" choose 'An offset from the current time such as "+1 day" or "-2 hours -30 minutes"', then enter:
now
view datetime field filter example
Note that the Date module is not yet available for Drupal 8, but D8 does have a (somewhat limited) core Datetime field, which is what I assume you are using.
Make sure yo enable the Date Views (date_views) module.
I want to perform a field validation,but the conditions are
1)The field should have 10 character.
2)off these 1st 5 character should be alphabets and next 5 character should be numeric digits
I performed validation for maximum length check,but rest of the thing how to perform.Is that can be done on a single "if" condition.
I am searching for the logic in google for performing that,but not got any idea.Can any one help me to perform the same.
forms.py for length check
def clean_bookref(self):
cd=self.cleaned_data
bookref=cd.get('bookref')
if len(bookref)<10 and re.match(r'[A-z0-9]+', bookref):
raise forms.ValidationError("Should be 10 digits")
return bookref
I am using this code to do but it is not working.
Thanks
Perhaps you could use something like his:
def clean_bookref(self):
cd=self.cleaned_data
bookref=cd.get('bookref')
if not re.match(r'^[A-Za-z]{5}[0-9]{5}$',bookref) :
raise forms.ValidationError("Should be of the form abcde12345")
return bookref