I am using jquery select2 method for multiple selections and for users to enter their own input it uses tags property.
Now I want to display the error message when a user enters wrong input.
Therefore, I am using formatResult property of select2 and checking regex for input.
When the input is correct; it returns the input else it returns error message from the function.
But this message is not coming in the format as it comes for select2 example "No matches found" and even when the error message is displayed, on clicking enter it takes the wrong input.
I want to display the message in correct format and not to select the wrong input on enter.
Please help. Below is my code:
$("#abc").select2({
minimumInputLength:1,
maximumInputLength:10,
formatResult: function(term){
if(term.text === 0)
return "Zero Not Allowed";
else return term.text;
}});
In this code, "zero not allowed" is not coming in the same format as "Please enter 1 or more characters" and when we press enter, zero gets selected.
Related
I'm working on a project where the UI test has a password field. The password is initially hidden, and the test checks to see if the value of the secureTextField is "••••••••".
// This works
let passwordValue = getValueOf(passwordTextField)
XCTAssertEqual(passwordSecureTextFieldValue, "••••••••")
Next, the password is revealed by tapping an eye icon that shows the password to the user as normal text, not dots. From there, I'd like to assert that the value of of the secureTextField is "password". Is there a property or strategy to do that?
Please see the script below:
void OnStart()
{
Alert(IsTradeAllowed()); //alert 1
Alert(IsTradeAllowed(NULL, TimeGMT())); //alert 2
Alert(IsTradeAllowed(Symbol(), TimeGMT())); //alert 3
Alert(IsTradeAllowed("GBPUSD", TimeGMT())); //alert 4
}
This returns:
true //for alert 1
true //for alert 2
false //for alert 3
false //for alert 4
As alert 2 returns: true, then I would expect alert 3 and alert 4 to return true.
I have tried running the code at multiple times of the day on weekdays. The code returns the same result at weekends. I have also tried putting the code in a script and an EA. Every time I get the same result. Is there an explanation for this? I have tried what is suggested here: https://www.mql5.com/en/docs/runtime/tradepermission
Symbol() returns: "GBPUSD". Each alert should return true in my mind, however this does not appear to be the case here. Incidentally I have notices that Symbol() returns the symbol at the top of the demo account watchlist if the script is run inside MetaEditor, however it returns the symbol displayed on the chart if run inside the demo account.
The broker is Oanda.
Update 04/03/21 at 19:55
I have now discovered that if I right click on the Market Watch and select: show all, then more symbols appear. I can then see that some symbols are greyed out and some symbols are not. The symbols that are not greyed out e.g. USDGBP-g return what I would expect when running the program above i.e. alert 1-alert 4 =true. The symbols that are greyed out e.g. USDGBP returns true; true; false; false in the program above. I now have two questions:
Why does: IsTradeAllowed(NULL, TimeGMT()); //alert 2 return true for symbols that are greyed out?
What does -g mean in GBPUSD-g?
IsTradeAllowed checks if the Expert Advisor is allowed to trade and trading context is not busy.
The version of the function without any arguments will check if the EA has been applied with the correct permissions ("Allow live trading" ticked and "AutoTrading" enabled).
The second form of the function:
bool IsTradeAllowed(const string symbol, datetime tested_time);
checks if the EA would be allowed to trade according to the specifications for the chart selected (to view this, from the Market Watch window right click a symbol, from the menu that pops up select "Specification").
For example
IsTradeAllowed(Symbol(), D'2021.03.06 12:00');
would check if the current symbol can be traded this coming Saturday (which should be false).
If you are getting undesirable results you should check that your broker has set the "Specifications" correctly.
EDIT
I've tested the command in OANDA which is the broker you are using and the command functions as expected.
NULL is not valid for a Symbol and its use makes the command function in its first form (ie timedate is ignored).
I would suggest rather than use Alerts to examine output, try the following.
string cmnt;
cmnt=StringConcatenate("Alert 1: ",IsTradeAllowed());
cmnt=StringConcatenate(cmnt+"\r\n","Alert 2: ",IsTradeAllowed(NULL, TimeGMT()));
cmnt=StringConcatenate(cmnt+"\r\n","Alert 3: ",IsTradeAllowed(Symbol(), TimeGMT()));
cmnt=StringConcatenate(cmnt+"\r\n","Alert 4: ",IsTradeAllowed("GBPUSD", TimeGMT()));
Comment(cmnt);
I tried your script in my ICMarkets version of MetaTrader4. With disabled auto trading i get result:
When I set auto trading to enable using Ctrl+E shortcut, in all cases script return true.
I recommend you to try this script on another account or different broker. If this will help, you should communicate with your broker about this issue. The last option is a reinstall MetaTrader to make sure, that all config files are correct.
I want the Information Message to show two lines of text.
Can this be done using one message class statement. Ex.
MESSAGE i001(z56_myclass) WITH lv_cust_id.
I tried putting the string of the short text with characters \n # \r \\n etc. but nothing worked. I don't know how to use long text editor for this particular requirement. Any help would be great.
You can't control the message carriage return in MESSAGE statement.
You can try instead with the following information popup
call function 'POPUP_TO_INFORM'
exporting
titel = 'Information'
txt1 = 'Registration successful'
txt2 = 'Customer Id is 0000001234'.
You have 4 text rows at your disposal (from txt1 to txt4).
I have a apple script program that I am programming and I want the text the user sends to open an application, But I keep getting error messages saying "Can't get application {"name_of_app"} of <>. The code I very simple and I cant figure out the problem
set deReturnedItems to (display dialog "How many spam messages?" with icon stop default answer "" buttons {"Quit", "OK"} default button 2)
set xpp to text returned of deReturnedItems
set theReturnedItems to (display dialog "How many spam messages?" with icon stop default answer "" buttons {"Quit", "OK"} default button 2)
set amt to the text returned of theReturnedItems
set daReturnedItems to (display dialog "Last thing, what should the spam message say?" default answer "" buttons {"Quit", "OK"} default button 2)
set msg to the text returned of daReturnedItems
repeat [amt] times
tell application [xpp]
activate
tell application "System Events"
keystroke [msg]
keystroke return
end tell
end tell
end repeat
Get rid of those square brackets. Don't use them for variables. Use underscores before and after if you must, like:
repeat _amt_ times
…
end
Also, you need to check to make sure your variable is an integer before you use it in the repeat block.
Incidentally, when you set a variable and then include it in brackets, that's applescript syntax for set the string to a list. For example:
set [x, y, z] to "123"
return x
-- returns "1", and y is set to "2", and z is set to "3"
I'm currently teaching myself the Dart language, and my first app doesn't seem to be working right. Here's the code that's causing trouble:
usrLoc = int.parse(query("#txtLoc").text);
When I try to run the app, it opens fine, but when I click the button that triggers this (and three other similar parses), the debugger stops and tells me "Source not found" for int._native_parse(), int._parse(), and int.parse().
Any help would be greatly appreciated.
The text property for the specified element #txtLoc returns an empty string.
The parse method requires that:
The source must be a non-empty sequence of base- radix digits, optionally prefixed with a minus or plus sign ('-' or '+').
You can specify an onError named argument in your call to parse, which takes a callback that handles the invalid input. E.g., if you want the parse call to return the value 42 for all invalid input, you can do this:
usrLoc = int.parse(query("#txtLoc").text, onError: (val) => 42);
If you really expect the element to have some text, you can store the result of query("#txtLoc").text into a separate variable and verify the value. It would also be interesting to check what the real element type is or which tag is marked with id #txtLoc.
If you want to get the content of an input element, you should use the value property instead of text:
query("#txtLoc").value