"12".match(/^(\d)+$/) # true
"1.2".match(/^(\d)+$/) # false
"dfs2".match(/^(\d)+$/) # false
"13422".match(/^(\d)+$/) # true
if($.cookie('query') === null) {
$.cookie('query', '1', {expires:7, path:'/'});
}
В качестве альтернативы вы можете написать функцию-оболочку для этого:
jQuery.lazyCookie = function() {
if(jQuery.cookie(arguments[0]) !== null) return;
jQuery.cookie.apply(this, arguments);
};
Тогда вам нужно будет только написать это в своем клиентском коде:
$.lazyCookie('query', '1', {expires:7, path:'/'});
this ??
$.cookie('query', '1'); //sets to 1...
$.cookie('query', null); // delete it...
$.cookie('query'); //gets the value....
if ($.cookie('query') == null){ //Check to see if a cookie with name of "query" exists
$.cookie('query', '1'); //If not create a cookie "query" with a value of 1.
} // If so nothing.
что еще вам нужно ??