|
|
You are looking for a simple email validator e.g.
function validateEmail(email) {
var regEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (regEx.test(email)) {
return true;
} else {
return false;
}
}
|
|
|
|
|
function validate(str){
if(str.indexOf('.') != -1 && str.indexOf('@')== str.lastIndexOf('@')){
return true;
}else{
return false;
}
}
|
|
|
|
|
or
function validate(str)
{
return str.split('.').length > 1 && str.split('@').length == 2;
};
or
function validate(str)
{
return /\./.test(str) && /^[^@]*@[^@]*$/.test(str);
};
|
|
|
|
|
Difference between compile and link function in angularjs?
|
|
|
|
|
|
Compiler is an angular service which traverses the DOM looking for attributes. The compilation process happens into two phases.
Compile: traverse the DOM and collect all of the directives. The result is a linking function.
Link: combine the directives with a scope and produce a live view. Any changes in the scope model are reflected in the view, and any user interactions with the view are reflected in the scope model. Making the scope model a single source of truth.
Some directives such ng-repeat clone DOM elements once for each item in collection. Having a compile and link phase improves performance since the cloned template only needs to be compiled once, and then linked once for each clone instance.
|
|
|
|
|
i have a problem when i post large json data through ajax post method i am getting an error request entity is too large i include
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security> and also include WCF service web config but no improvement at all. i changed the configuration Editor setting IIS then also no improvement.can any one help me in this regard.
|
|
|
|
|
As you talking about WCF...
Look for maxReceivedMessageSize in your binding settings...Also check readerQuotas...
If it is not WCF and/or about SSL connection check uploadReadAheadSize...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Actually on a button click i am sending large json data to WCF Rest service method but it is not processing. it shows bad request from the browser itself and when i reduce the json size the data is posted to a WCF service.
|
|
|
|
|
There is a error code attached to the message?
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
I now consider that the way that 'undefined' is implemented in JavaScript represents a flaw in the language.
IMHO, everything (at least variables) in JavaScript are Objects, but I just realize that variables that are 'undefined', are not.
It is unfortunate that constant values are not objects. It would be a nice to have. For instance, it is possible to do:
var a=1; a.toString(); and not
1.toString(); .
With regards to undefined, it isn't possible to do neither
var a=undefined; a.toString(); nor
undefined.toString();
Hence it breaks several principles that Programming Languages should respect.
If 'undefined' were an object, it could act as a Null Object, and all variables would automatically have a
Null Object.
It would then suffice to do something like:
Object.prototype.isMyObject=false;
MyObject.prototype.isMyObject=true;
and then one could always write:
if(anyvar.isMyObject){ }
without falling in the undefined issue.
However, I do understand that today many developers may partly rely on 'undefined' resulting in an exception to detect flaws in their programs. Therefore a new option might be added to JavaScript, much like "strict" in order to indicate that 'undefined' should act as a Null Object. But that might not even be necessary, as the exception could simply be thrown only when trying to get a missing member of the object, as in:
undefined.missingVariable or
undefined.missingFunction() .
So in conclusion: having undefined variables behave as Objects would make the JavaScript language "more complete", and having constants (like the number 1) behave as Objects would take it even one step further.
If those impacting the definition of the language could consider that, I would be quite happy about it.
--
Mario DW
modified 1-Aug-15 8:23am.
|
|
|
|
|
First of all - numbers and strings are not object in JavaScript, but just like undefined are 'primitive types'...The difference is that for string and number there is a wrapping object but not for undefined...You are welcome to create one (and resolve your problem undefined not being an object)!!!
As for the 1.toString() part...It is not hing more than a parsing problem...In JavaScript there is only number, no int or float or other sub-types...
So 1.t is a syntax problem only - try 1.0.toString() and see how it works (so constant values are objects, when it suits the parser/compiler)...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Peter, thanks for the interesting feedback.
Thanks to your keywords I found this: ECMAScript Language Specification paragraph 7.1.13 on page number 43 indicates that 'undefined' and 'null' are not converted into an object.
So yes, you are right that numbers and strings are not objects, but they are "coerced" (if that is the right word) into objects temporarily when the context kind of asks for it. It would be nice that that also applies to 'undefined' and 'null'.
I do not see a way to define the "automatic" and "temporary" conversion to an object myself, just the way it happens for strings, numbers and booleans.
If you have a way, I'll take it .
|
|
|
|
|
Think about how JavaScript enclosed inside DOM...
When you write var n = new Number();, Number is a shortcut for window.Number. Same goes for undefined (it is a property of the window object, but not number or string)...The problem is that since ECMA 5 it is read-only and for that can not be overridden...
So there is no way to 'fake' and automatic boxing of undefined in the context of window, but you can create an object that does it and create your own closure (scope) that will define undefined as that object...
If you ever saw an opening line like this...
(function (window, document) {
})(window, document);
Didn't you asked yourself why those parameters, especially undefined? So it is because before ECMA 5 undefined was mutable...
Now if you do not bring undefined in (to protect yourself) into your closure, you can define an the name 'undefined' with other value and start using it inside your closure...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
I've tried the following, and 'undefined' does not seem 'fakable' as you say. A local variable can assume another value, but the value of that variable is of course not assumes by undefined variables.
(function(window){
var undefined='a';
console.log(undefined);
console.log(window);
console.log(a);
})(undefined)
The following code also changes the local value of 'undefined', but not the 'undefined' of 'a' itself.
(function(undefined){
console.log(undefined);
console.log(a);
})('a')
|
|
|
|
|
It just shows how fundamentally 'undefined' is deep in the JavaScript engine...
As you (we) can not change it from the outside, you may talk to the committee...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Instead of 1.toString () we can use (1).toString().It will work fine by the java script perser.
|
|
|
|
|
Hi,
I am trying to make a simple javascript slideshow on my website. I'm not to bad with HTML and CSS but have no idea about javascript.
If someone could tell me why this slideshow is not working and exactly where and in what tags I need to put it in my code that would be amazing. I ideally want it to start when the user scrolls down to it (so when visible).
[^]
Thanks
|
|
|
|
|
I would like to track client mac address when he/she is browsing my website using javascript
|
|
|
|
|
JavaScript is not designed for this functionality, that is why there are server-side languages which can work around with request headers to provide you with other details of the client.
The following link works, only in Internet Explorer using ActiveX control (but still needs permission from user). http://stackoverflow.com/questions/16556700/how-to-get-client-mac-address-by-using-javascript[^]. I would still recommend, that you try to use server-side language such as ASP.NET, PHP etc to get these details.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
What is the proper syntax for incrementing or decrementing NOT by 1, but rather with another number in a For Loop? I am trying to count by threes and
"for(i=0;i<=30;i+3;) doesn't work. Why? The books and tutorials are great at telling you how to increment by 1 but rarely cover anything else.
|
|
|
|
|
The operator you are looking for is += like so:
<br />
for(i = 0; i <= 30; i += 3)
Also you have a spurious semicolon before the close bracket.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
For example:
if ($(e.target).parents('.jqx-tree').length > 0) {
return false;
}
return true;
WTF is the reason I can't just do a return on > comparison???
Marc
|
|
|
|
|
I can't reproduce the problem. Given:
var result = $(" ... ").length > 0;
alert(typeof result);
alert(result);
the code displays "boolean" and "true".
What output do you get if you try:
var result = ($(e.target).parents('.jqx-tree').length > 0);
alert(typeof result);
alert(result);
return result;
As a last resort, there's always the "!! " trick to convert to a boolean value:
return !!($(e.target).parents('.jqx-tree').length > 0);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|