/    Sign up×
Community /Pin to ProfileBookmark

Insert Confirmation

How do I display another window to confirm the details entered by the user into a form?

THanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@steelersfan88Mar 25.2004 — I am going to post an article about this, but here you go:[code=php]<script type="text/javascript">

var times = 0

function checkVals() {
var theField = new Array;
var theName = new Array
var numFields = 2 //five text boxes to validate
for(var i=0;i<numFields;i++) {
// id your fields as myText0, myText1, etc.
theField[i] = document.getElementById('myText'+ i).value
theName[i] = 'myText'+ i
}
var errors = ""
var confirm = ""
for(var k=0;k<theField.length;k++) {
if(!/^[0-9]+$/.test(theField[k])) {
errors += "The Text Field, "+ theName[k] +", is invalid.<BR><BR>"
}
confirm += theName[k] +": <B>"+ theField[k] +"</b><BR>"
}
if(errors.length > 1) {
var newWin = window.open('','_blank',config="toolbars=no,status=nu,menubars=no,directories=no,scrollbars=yes,height=280,width=300")
newWin.document.write("<center><h1>Errors:</h1>")
newWin.document.write(errors)
newWin.document.close()
return false;
}
else if(times == 0) {
var newWin2 = window.open('','_blank',config="toolbars=no,status=nu,menubars=no,directories=no,scrollbars=yes,height=300,width=170")
newWin2.document.write("<center><h1>Confirm<BR>Input:</h1></center>")
newWin2.document.write(confirm)
times = 1
return false;
}
else {
return true;
}
}

function resetTimes() {
times = 0
}

</script>

<form name="myForm" onSubmit="return checkVals()" action="">
Enter numbers: <input type="text" name="myText0" id="myText0" onchange="resetTimes()"><BR>
Enter numbers: <input type="text" name="myText1" id="myText1" onchange="resetTimes()"><BR>
<input type="submit" value="Validate Numbers!">
</form>[/code]
Note, that this form must be changed, and I have made a short validator that makes sure fields are filled in. It can be configured if you reply!

NOTE: The script will continue to confirm entries until you do NOT make a change in them. Then it will submit.
×

Success!

Help @gracenmy 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,
)...