I have kendo numeric text box. If i type number like 123456, the widget automatically format the number with comma and dollar symbol as expected. However if i copy and paste number with comma, for example 123,456, the widget does not accept that as input.
JSfiddle demo
How do i fix this or override the defualt behavior
place comma by separated thousand value and place currency of country for Kendo grids
columns.Bound(e => e.Amount).ClientTemplate("#= Amount !== null ? kendo.toString(Amount, 'c', 'en-US') : ''#").Width("5%").Title("Amount");
For instance:
kendo.toString(1234.23, ‘c’, ‘de-DE’) –> 1.234,23 €
kendo.toString(1234.23, ‘c’, ‘sv-SE’) –> 1.234,23 kr
kendo.toString(1234.23, ‘c’, ‘en-US’) –> $1,234.23
only comma separated with two decimal points:
columns.Bound(e => e.Amount).ClientTemplate("#= kendo.format('{0:N2}', kendo.toString(Amount)) #").Width("5%").Title("Amount");
for Example - 1234.44 -> 1,234.44
1234 -> 1,234.00
I think it is a bug in Kendo...
In the source code for the NumericTextBox, there is a _paste handler that appears like it is trying to sanitize the input against the culture's numeric format but then it validates against the unsanitized value...seems to be it should use the sanitized value.
Here's the implementation:
_paste: function (e) {
var that = this;
var element = e.target;
var value = element.value;
var numberFormat = that._format(that.options.format);
setTimeout(function () {
var result = that._parse(element.value);
var isValid = that._numericRegex(numberFormat).test(element.value);
if (result === NULL || that._adjust(result) !== result || !isValid) {
that._update(value);
}
});
},
So, if you paste "123,456", it will _parse() it to 123456(because it knows that "," is the thousands separator) but then the isValid check is still checking against the "123,456" which is bad and so it reverts to the previous value.
If you change the isValid line to
var isValid = that._numericRegex(numberFormat).test(result);
so that it validates against the sanitized value, then it all appears to work as you expect it to....otherwise I can't really see why the sanitize it in the first place.
I realize that changing the kendo source code it not really a valid solution, but I do believe this is a bug that you may have to work around it until it is fixed.
If you have a kendo license, I would contact their support to verify if it is a bug or not. If you don't have a license, let me know and I will submit a request when I have time as I do have a license.
Related
How do I write this test in Cypress?
enter image description here
I have to confirm that either the headline or paragraph should contain the same keyword.
It's better to have JQuery elements in hand before the assertion so that you can use JQuery methods on them. cy.get() acts just like $(...) in JQuery, it will be enough to have the elements. (more here)
Once u have the elements, i.e. $el1 and $el2 below, then you can get their text via .text() method (more here) and then you can write your assertion.
Instead of a separate assertion, below I used a single one and checked if either of them includes the desired text by using || operator.
cy.get('first-el').then($el1 => {
cy.get('second-el').then($el2 => {
const inEl1 = $el1.text().includes('FIFA');
const inEl2 = $el2.text().includes('FIFA');
expect(inEl1 || inEl2).to.be.true;
});
});
I have this following element which contain a string for Practitioner, its value is 1- zzz. How to validate after - it shouldn't be null. Even if there is a string or empty. It shouldn't print null. Also want to select the value under Practitioner (currently hard coded the position of the element as 2)
<div class="styles__container___BfTYi">
<div class="styles__subHeader___18Yg1">Practitioner</div>
<div class="styles__data___1senX">1- zzz</div>
</div>
I have the following code to retrieve the text,
cy.get(pageSelector.practitionerValidator).eq(2).then(function($getText) {
let practitionerName = $getText.text();
var validateLastName = practitionerName.split(' ');
cy.log(validateLastName[1]);
expect(validateLastName[1]).to.not.equal('null');
})
You can directly check that the entire string is not null like this:
cy.get('.styles__data___1senX').then(($ele) => {
expect($ele.text()).to.not.be.null
})
Or if you want to check that your inner text is not empty you can do:
cy.get('.styles__data___1senX').then(($ele) => {
expect($ele.text()).to.not.be.empty
})
You can find the selector from the text Practitioner like this:
cy.contains('Practitioner')
.parent()
.within(() => {
cy.get('div[class*="styles__data__"]').then(($ele) => {
expect($ele.text()).to.not.be.null
})
})
Appreciate the level of detail you gave.
I will be going off this assumption.
the Practitioner string will be random can spaces or no spaces after the - (ie 34- sdfwe, 3- , 1- )
I would use a regex to check the format of the string to check the string starts with a digit followed by a dash and a space with either a string, spaces, or nothing. /\d+\-\s(\w+|\s+)?/
Your code would look a bit like this.
cy.get(pageSelector.practitionerValidator)
.eq(2)
.invoke('text') // get text
.should('match', /\d+\-\s(\w+|\s+)?/) // use regex assertion
Anyone knows how to avoid firefox console to group log entries?
I have seen how to do it with firebug https://superuser.com/questions/645691/does-firebug-not-always-duplicate-repeated-identical-console-logs/646009#646009 but I haven't found any group log entry in about:config section.
I don't want use Firebug, because it's no longer supported or maintained and I really like firefox console.
I try to explain better, I want console to print all logs and not the red badge with number of occurences of one log string:
In the above picture I would like to have two rows of the first log row, two rows of the second and three of the third.
Is this possible?
Thanks in advance
Update [2022-01-24]
Seems like the below option doesn't work as expected. feel free to report it as a bug
Update [2020-01-28]
Firefox team added option to group similar messages, which is enabled by default.
You can access to this option via Console settings
Open up Firefox's dev tools
Select Console tab
Click on gear button (placed at the right of the toolbar)
Change the option as you wish
Original Answer
As I mentioned in comment section, There is no way to achieve this at the moment. maybe you should try to request this feature via Bugzilla#Mozilla
Also you can check Gaps between Firebug and the Firefox DevTools
As a workaround you can append a Math.random() to the log string. That should make all your output messages unique, which would cause them all to be printed. For example:
console.log(yourvariable+" "+Math.random());
There is a settings menu () at the right of the Web Console's toolbar now which contains ✓ Group Similar Messages:
To solve this for any browser, you could use this workaround: Override the console.log command in window to make every subsequent line distinct from the previous line.
This includes toggling between prepending an invisible zero-width whitespace, prepending a timestamp, prepending a linenumber. See below for a few examples:
(function()
{
var prefixconsole = function(key, fnc)
{
var c = window.console[key], i = 0;
window.console[key] = function(str){c.call(window.console, fnc(i++) + str);};
};
// zero padding for linenumber
var pad = function(s, n, c){s=s+'';while(s.length<n){s=c+s;}return s;};
// just choose any of these, or make your own:
var whitespace = function(i){return i%2 ? '\u200B' : ''};
var linenumber = function(i){return pad(i, 6, '0') + ' ';};
var timestamp = function(){return new Date().toISOString() + ' ';};
// apply custom console (maybe also add warn, error, info)
prefixconsole('log', whitespace); // or linenumber, timestamp, etc
})();
Be careful when you copy a log message with a zero-width whitespace.
Although you still cannot do this (as of August of 2018), I have a work-around that may or may not be to your liking.
You have to display something different/unique to a line in the console to avoid the little number and get an individual line.
I am debugging some JavaScript.
I was getting "Return false" with the little blue 3 in the console indicating three false results in a row. (I was not displaying the "true" results.)
I wanted to see all of the three "false" messages in case I was going to do a lot more testing.
I found that, if I inserted another console.log statement that displays something different each time (in my case, I just displayed the input data since it was relatively short), then I would get separate lines for each "Return false" instead of one with the little 3.
So, in the code below, if you uncomment this: "console.log(data);", you will get the data, followed by " Return false" instead of just "false" once with the little 3.
Another option, if you don't want the extra line in the console, is to include both statements in one: "console.log("Return false -- " + data);"
function(data){
...more code here...
// console.log(data);
console.log("Return false ");
return false;
}
threeWords("Hello World hello"); //== True
threeWords("He is 123 man"); //== False
threeWords("1 2 3 4"); //== False
threeWords("bla bla bla bla"); //== True
threeWords("Hi"); // == False
I Guys
In forms I use,
onKeyUp="this.value = this.value.toUpperCase()"
To force upper-case. However for such as name fields. How do you force the upper letter to be upper-case only while the user is typing. I know INITCAP will do that but need to do as user is typing, if that makes sense.
Any help will be much appreciated.
This is a javascript question then, not and Oracle or APEX question. It shouldn't make any difference what the environment is as long as you have access to the DOM events with javascript functions. e.g. http://www.w3schools.com/jsref/event_onkeyup.asp
If you do a search there are lots of examples to Initcap a string in javascript, just pass in the string and reset the item in the dom e.g.
function capitalizeEachWord(str) {
return str.replace(/\w\S*/g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
I tried to solve this problem.
For that I created JavaScript function which check first letter capital ,if not then it display alert and revert text.
please check following code for text item:
function checkUpper()
{
var x = $x("P6_TEXT");
if (x.value.trim().substring(0,1) != x.value.trim().substring(0,1).toUpperCase()) {
alert ('First letter Must be in upper case');
x.value = x.value.trim().substring(0,x.value.trim().length-1).toString();
}
}
And set item P6_TEXT attribute as
onKeyUp="checkUpper();"
In the field custom attributes put this JS code:
onKeyUp="this.value = this.value.substring(0,1).toUpperCase()+this.value.substring(1).toLowerCase();"
You could use content modifiers from Universal Theme https://apex.oracle.com/pls/apex/apex_pm/r/ut/content-modifiers
I needed text in a page item to be uppercase and under Advanced I set the css classe to
u-textUpper
u-textInitCap - Sets The First Letter In Each Word To Use Uppercase
I have a StringLength validator on textarea
[StringLength(10, ErrorMessage = "The {0} must be {1} characters or less")]
So when I press enter and then type 9 characters, the client validation does not display any errors; but if I submit the form, server validation says that there is more than 10 characters.
So on client side enter means one character and on server, two. It is not the same behavior.
Probably I would need to implement my own validator which would do it, right?
Or is there any validators I may use instead of StringLength, to validate textarea content length correctly?
See my answer here: New line characters in text area increases text length in C#
You can change the default behavior for getLength to double count newlines by adding the following to your JS somewhere.
$.validator.prototype._getLength = $.validator.prototype.getLength;
$.validator.prototype.getLength = function (value, element) {
// Double count newlines in a textarea because they'll be turned into \r\n by the server.
if (element.nodeName.toLowerCase() === 'textarea')
return value.length + value.split('\n').length - 1;
return this._getLength(value, element);
};
Add attribute to your property
[RegularExpression(#"^[\s\S]{0,10}$",ErrorMessage="maximun length must be 10")]
then in your view
<%: Html.ValidationMessageFor(m => m.MyText) %>
I had the same issue recently, but since both the .Net code and Sql Server were considering one line break as two chars, I ended up changing the client side logic to also consider line breaks as two chars:
$('textarea[maxlength]').keyup(function () {
var lineBreaks = $(this).val().split('\n').length - 1;
var charsUsed = $(this).val().length + lineBreaks;
if (charsUsed >= maxlength) {
$(this).val($(this).val().substr(0, maxlength - lineBreaks));
charsUsed = maxlength;
}
var remaining = maxlength - charsUsed;
$('#MyCounter').html("<strong>" + remaining + "</strong> characters remaining");
});