/    Sign up×
Community /Pin to ProfileBookmark

Form Validation and submission

HI,
I have a form and when i click on the submit button it should check the validity of the values entered in the form and either one of the following should happen
1) if the validation fails i want to show an warning/error message and do nothing more
2) If forms contains all valid data i want to invoke an xyz.asp program with out refreshing the current page and also want to pop up status window.
Does any one know how to do this using java script.
Here is the sample code(which is not working properly):

<form action=”xyz.asp” id=””frm1″” method=”POST” name=”frm1″ target=”nextpage”>
<input maxLength=”5″ name=”fquantity” size=5 value=”2″>
<input type=”submit” value=”Submit” name=”click here” onClick=”return validateForm(this);”>
</form>
function validateForm(form)

var quant = form.fquantity.value
if ( (isNaN(quant) == true || quant < 1 || quant > 10000))
alert(“Please enter the quantity”);
form.fquantity.focus();
return false;
}
else
{
window.open(“xyz.asp”, “nextpage”, “height=220,width=350,resizable=no,location=no…”);
return true;
}

}
I appreciate any help…
Thanks,

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliAug 20.2003 — if your concern is only to invoke the *.asp page then you only need to do this

instead of this

window.open("xyz.asp", "nextpage", "height=220,width=350,resizable=no,location=no...");

return true;


window.open("xyz.asp", "nextpage", "height=220,width=350,resizable=no,location=no...");

return false;

thios will do that..however if you want to pass the form data to asp page then there is not way to not refresh the form page..because it has tosend the data to asp and then recieve back.
Copy linkTweet thisAlerts:
@ScriptageAug 20.2003 — You can dynamically create a new child element with the src as xyz.asp, this would pass data to the asp page. I think it was Vladdy (not sure) who wrote an excellent tutorial on how to do this. search for him and look back at his posts.

Regards
Copy linkTweet thisAlerts:
@VladdyAug 21.2003 — [i]Originally posted by Scriptage [/i]

[B] ... I think it was Vladdy (not sure)...[/B][/QUOTE]

Guilty as charged?

Here is the link: http://forums.webdeveloper.com/showthread.php?s=&threadid=5810

Be advised that this method works only in browsers which allow dynamic creation of script node. Gecko and IE5+ have tested positive, Opera - negative, don't know about the others.

Also, since the data is passed to the server in the form of query string so the amount is limited to ~2K depending on the type of proxies you have in-beween (when I tried to go the straight to my local host I was able to "transmit" 96K ? ? ). It should be enough for "database browsing" type applications but may be a problem if your form contains decent chunk of data
Copy linkTweet thisAlerts:
@s_allamneniauthorAug 21.2003 — Thank you all,

i got it working...
×

Success!

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