/    Sign up×
Community /Pin to ProfileBookmark

if a string starts with a value

this is not working it is saying startsWith is not a function.

how can I get this to work. I need to disable a button if the string starts with Admin@

[CODE]
function(sm, row, rec) {
if (rec.get(‘objname’).startsWith(“Admins@”)) {
Ext.getCmp(‘deleteButton’).disable()
}
else Ext.getCmp(‘deleteButton’).enable();
}
}
[/CODE]

can someone show me a way to ge this to work

thanks

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Dec 08.2008 — My personal preference would be using regular expressions like thisif (/^Admins@/.test(rec.get('objname'))) {But I think this would work as well<i>
</i>if (rec.get('objname')[b].substring(0,7) == "Admins@"[/b]) {
I cannot this of any other way to do it.

[url=http://www.regular-expressions.info/javascript.html]Regular expressions[/url]
Copy linkTweet thisAlerts:
@mthorauthorDec 08.2008 — thank you for the reply

(/^Admins@/.test(rec.get('objname')))

works perfect.

the second on I tried earlier but after the @ the string could be any length depending on what the user adds in there.

but hte first way worked great.

thanks
Copy linkTweet thisAlerts:
@Declan1991Dec 09.2008 — if ("Admins@asdfasfd"[B][COLOR="Red"].substring(0,7)[/COLOR][/B] == "Admins@") {will work as well, but I prefer the first method anyway.
×

Success!

Help @mthor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...