/    Sign up×
Community /Pin to ProfileBookmark

Some JS code works, some doesn’t

I have built a form on my network. I have put several javasripts in the form. The thing that is driving me nuts is; while codes such as highlight fields, copy fields and text limit work, others, such as Sentence case and Auto enter curent date don’t. Any suggestions?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@BIOSTALLApr 09.2010 — Any code examples to show?
Copy linkTweet thisAlerts:
@dcrandall0575authorApr 09.2010 — For Sentence case, I have;

function sCase(){

val=document.Application.convert.value;

result=new Array();

result2='';

count=0;

endSentence=new Array();

for (var i=1;i<val.length;i++){

if(val.charAt(i)=='.'||val.charAt(i)=='!'||val.charAt(i)=='?'){

endSentence[count]=val.charAt(i);

count++

}

}

var val2=val.split(/[.|?|!]/);

if(val2[val2.length-1]=='')val2.length=val2.length-1;

for (var j=0;j<val2.length;j++){

val3=val2[j];

if(val3.substring(0,1)!=' ')val2[j]=' '+val2[j];

var temp=val2[j].split(' ');

var incr=0;

if(temp[0]==''){

incr=1;

}

temp2=temp[incr].substring(0,1); temp3=temp[incr].substring(1,temp[incr].length);

temp2=temp2.toUpperCase();

temp3=temp3.toLowerCase();

temp[incr]=temp2+temp3;

for (var i=incr+1;i<temp.length;i++){

temp2=temp[i].substring(0,1);

temp2=temp2.toLowerCase();

temp3=temp[i].substring(1,temp[i].length);

temp3=temp3.toLowerCase();

temp[i]=temp2+temp3;

}



if(endSentence[j]==undefined)endSentence[j]='';

result2+=temp.join(' ')+endSentence[j];

}



if(result2.substring(0,1)==' ')result2=result2.substring(1,result2.length);

document.Application.convert.value=result2;

}



for the date, i have;

function autoDate () {

var tDay = new Date();

var tMonth = tDay.getMonth()+1;

var tDate = tDay.getDate();

if ( tMonth < 10) tMonth = "0"+tMonth;

if ( tDate < 10) tDate = "0"+tDate;

document.Application("tDate").value = tMonth+"/"+tDate+"/"+tDay.getFullYear();

}



function addLoadEvent(func) {

var oldonload = window.onload;

if (typeof window.onload != 'function') {

window.onload = func;

} else {

window.onload = function() {

if (oldonload) {

oldonload();

}

func();

}

}

}



addLoadEvent(function() {

autoDate();

});



bothy have the corrisponding codes in my form. If yow want to see the form, it's at http://www.denniscrandall.com/siteapplicants/app.html
×

Success!

Help @dcrandall0575 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...