|
I have tried by putting the input-filter as below:
input-filter='[A-Za-z0-9 \-_@#]{1,20}', it is accepting all the Alpha Numeric values but not allowing the 3 special characters that I want it to allow: -,@,#, can you please help me in this regards.
If mouse functions are better, can you please give me an example here - thanks in advance my friend.
|
|
|
|
|
OK - lets go about this analytically:
It works for A-Za-z0-9
Now add just one of your special characters at a time and see which, if any work - or what we're really looking for - is which one is breaking your string.
Note, also, that shortcuts exist for standard numeric and alpha ranges:
[^] And, if I read it correctly, '\w' is the equivalent of '0-9A-Za-z' and the do mention the hyphen character, as well.
- \d – is the same as [0-9]
- \w – is the same as [a-zA-Z0-9_],
- \s – is the same as [\t\n\v\f\r ], plus few other rare unicode space characters.
Comes from that page.
Find out the character that's killing you. It will help you remember three things (1) how to hunt for the problem (2) when you find the bad actor(s), why they're bad, (3) burn it into your mind so it is not only remembered but parallel problems are identified in advance.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
OK I have written a function for onKeyUp, as below, but what I want is to remove those special characters that are not from the 3 in the above list -, @, #.
Can you please modify the function how can I remove them automatically? Or suggest me for something. Thanks in advance my friend,
JS function:
forTest(e) {
e = 'some test';
},
Ember Control (html input-tag control):
{{#tag-input
tags=tags
addTag=(action 'addTag')
onKeyUp=(action 'forTest')
removeTagAtIndex=(action 'removeTagAtIndex')
as |tag|
}}
{{tag}}
{{/tag-input}}
|
|
|
|
|
1) Whatever ember-control is, I don't use it. I use straight javaScript, no "frameworks".
2) Did you try, as I suggested yesterday, eliminating some of your special characters from your regex expression and see which of them work as expected? You didn't say.
OK - why I send you into this direction: I use php/javaScript/SQL all in the same page, which is often a generated page. It can absolutely not work on the basis of improperly handled nested single and double quotes - which only co-exist on the final page and it's occasionally not what one expects. Unless it sticks out in an obvious way (good luck) I need to roll back parts of the page creation until it works and then I have a point to look for what's not phased correctly.
You are in a similar situation: plain alpha-numeric filtering works. Your entire regex expression, however, does not. Do it piece by piece: only the alpha-numeric and then add one of your special characters. If it works, add another. If it fails - try another (not add to a failed version), which hopefully will now work without the know failure-causing character. For that matter, you may even wish to try just reversing the order of your special characters near the end of your regex expression.
But you've not told me what you have tried to uncover the problem - I want to teach you how to do this; much more valuable than the expression, itself.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Yes I tried, its the mask value, which I am setting as mask='********************' is not allowing me to enter any special characters, if I remove it, its allowing all the characters and without limit.
Yes my exposure to JavaScript and Frameworks is limited, I am not able to find solution.
If I remove mask='********************', its not only allowing me all characters but unlimited number of characters, even if I try to set the max length property to 20 - need some help, thank you.
|
|
|
|
|
Get rid of the template!
In the same function where you use the regex expression to clean the string, get the length of the cleaned string and if it's greater than 20 (or whatever value you like) the send back a "Substring" of length 20 as the value.
Simple as that. No annoying masks to worry about for some so simple as a max-length string constraint. If your string's name is 'mystring'
if( mystring.length > 20)
mystring = mystring.substring(0, 20);
It takes some learning, but all the tools you need are already in javaScript.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I have a box composed from 5 images placed over each other to create a one picture. So I need to create a pixelated div to make this box pixelated. Because I have 5 images and the color of these images can be changed dynamically so I can't solve this problem using canvas. Any solution, idea, please!!
|
|
|
|
|
HTML:
<div class="tag-container" id="tag-container">
tag1tag2tag3
</div>
<input type="text" value="" placeholder="Add a tag" id="add-tag-input" />
jQuery:
$(document).ready(function(){
$(function(){
$("#add-tag-input").on({
focusout : function() {
var txt = this.value.replace(/[^a-z0-9\+\-\.\#]/ig,'');
if(txt) $("<span/>", {text:txt.toLowerCase(), appendTo:"#tag-container", class:"dashfolio-tag"});
this.value = "";
},
keyup : function(ev) {
if(/(188|13)/.test(ev.which)) $(this).focusout();
}
});
$('.tag-container').on('click', 'span', function() {
if(confirm("Remove "+ $(this).text() +"?")) $(this).remove();
});
});
}); And CSS:
.tag-container {
max-width: 300px;
}
.dashfolio-tag {
cursor:pointer;
background-color: blue;
padding: 5px 10px 5px 10px;
display: inline-block;
margin-top: 3px;
color:#fff;
margin-right: 4px;
background:#789;
padding-right: 20px;
}
.dashfolio-tag:hover{
opacity:0.7;
}
.dashfolio-tag:after {
position:absolute;
content:"×";
padding:2px 2px;
margin-left:2px;
font-size:11px;
}
#add-tag-input {
background:#eee;
border:0;
margin:6px 6px 6px 0px ;
padding:5px;
width:auto;
}
We are using less, instead of CSS, can you please help in converting the above code into Ember JS
|
|
|
|
|
I suggest you describe where you are stuck. Asking someone to do all the work for you will not likely get you any help.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I did resolve it buddy, here it is:
{{#tag-input
tags=tags
addTag=(action 'addTag')
removeTagAtIndex=(action 'removeTagAtIndex')
as |tag|
}}
{{tag}}
{{/tag-input}}
|
|
|
|
|
const base = [
{id: 1,name: 'A1'}, {id: 11,name: 'A11'},
{id: 12,name: 'A2'}, {id: 111,name: 'A111'},
{id: 112,name: 'A112'}, {id: 121,name: 'A121'},
{id: 122,name: 'A122'},
{id: 2,name: 'A2'},{id: 3,name: 'A3'},{id: 4,name: 'A4'}
];
const tree = [
{id: 1, parent:0, level: 'L1'},
{id: 11, parent:1, level: 'L2'},
{id: 111, parent:11, level: 'L3'},
{id: 112, parent:11, level: 'L3'},
{id: 12, parent:1, level: 'L2'},
{id: 121, parent:12, level: 'L3'},
{id: 122, parent:12, level: 'L3'},
]
i have two object one is base another one is tree. if i pass the 'id=11' it has to remove the [id:11]'s level 'L2' and its top level 'L1' id from the base object and result the remaining values. the below result am expecting
const result = [
{id: 111,name: 'A111'},
{id: 112,name: 'A112'}, {id: 121,name: 'A121'},
{id: 122,name: 'A122'},
{id: 2,name: 'A2'},{id: 3,name: 'A3'},{id: 4,name: 'A4'}
];
how to achieve this?
modified 5-Sep-20 13:11pm.
|
|
|
|
|
Hi,
Tried so many things and nothing works.
It works in Edge but not in IE, is it possible at all?
Tried a lot of combination as suggested (location.href and window.location.href, replace etc.).
IE settings for redirection were allowed by default.
This was the last try:
if(!!navigator.userAgent.match(/Trident.*rv\:11\./))
{
window.location.href = "https://google.de";
window.location.reload();
}
modified 2-Sep-20 7:25am.
|
|
|
|
|
Just setting the location.href or using location.assign should work fine.
location.href = "https://google.de";
location.assign("https://google.de"); Location: href - Web APIs | MDN[^]
Location: assign() - Web APIs | MDN[^]
NB: Call one or the other, not both. And don't call reload afterwards, since that reloads the current page.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello,
that's weird. It doesn't work. I tested it in my IE (V 11.1016.18362.0) on my Windows 10 PC.
Could anybody confirm that it works in his IE?
I don't know how else to test it as in my browser.
modified 4-Sep-20 6:28am.
|
|
|
|
|
It's solved.
Had an Error Code caused by UrlSearchParam(?!). It prevented the website in IE to run the rest of the code. Thanks all.
|
|
|
|
|
|
I'm executing a function on onclientclick.
function GetUrlPage() {
var pplid = document.getElementById('<%= tbPersonId.ClientID %>').value;
var newwindow = window.open('MXUrl.aspx?PersonId=' + pplid, null,
"Width=475px, Height=500px; top=42px; scrollbars=1; toolbar=0; titlebar=0; menubar=0; status ;");
Nothing happens. If I add an alert("some message"); after the window.open everything works great.
I can only assume it is just blowing thru the code but I don't know how to make it wait.
Don't do much in javascript so am really at a loss. Really appreciate any help you can give me.
|
|
|
|
|
Most likely it is scope issue. You create the local variable newwindow inside the function. So as soon as you exit the function that variable is destroyed and its corresponding window with it. Put the variable outside the function so it will exist for as long as it is needed.
|
|
|
|
|
Thanks for the reply but unfortunately no luck. I tried setting focus to the new window. Checked for document readystate. Only thing that works is adding an alert after the window.open. What's really baffling is that I have this same exact code in multiple places with the same project and it works flawlessly. Truly at a loss.
|
|
|
|
|
Sorry, I cannot offer any suggestions, other than using the debugger to trace what is happening.
|
|
|
|
|
I will. Thanks for responding.
|
|
|
|
|
I changed the call from Window.open to Response.Redirect and it worked fine. Not what I want to do but the only solution I could find.
|
|
|
|
|
That suggests to me that you're trying to open a new window as soon as the current page loads. Most browsers will block popups which aren't launched as the direct result of user interaction - eg when the user clicks a button.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ok, first please have pity/patience with me as I'm just starting to learn coding. I'm following a course on Udemy to learn JS and on one part im not getting the same result as shown on the video- maybe some kind of wrong setting or something. Heres the code:
let car = {
make: "volvo",
speed: 160,
engine: {
size: 2.0,
make: "bmw",
fuel: "petrol",
pistons: [
{ maker: "BMW" },
{ maker: "BMW2" }
]
}
};
I know, simple, like toddler like simple but im just starting out. I open the live preview and i type car and im supposed to get all the details about the nested objects and array but all i get is this:
{make: "volvo", speed: 160, engine: {…}}
Nothing else. Any help?
THanks,
Dave
|
|
|
|
|
What do you mean by "all the details about the nested objects"? What output are you expecting? The reason you are seeing what you are seeing is because that's what "car" is, it is all of those properties. If you want to drill down to individual properties then you do that like
car.make
car.pistons[0].maker
car.pistons[1].maker
and so on.
|
|
|
|
|