View Full Version : Alert onSubmit page

11-07-2013, 08:32 AM
When the input-text is too big or too small, you get a popup-message.
e.g. 1. input : "e" - width : "100 cm" - popup : "text is too big ..."
e.g. 2. input : "dynamicforum" - width : "5 cm" - popup : "text is too small ..."

I want a popup-message ("Please edit input text") onSubmit the page when the input-text is too big or too small.

TESTPAGE (http://www.stickers.be/X_Tests/detail-eigentekst-Afmeting-Alert.asp)

script : http://www.stickers.be/Eigen_Tekst_Afmeting.js
(alerts on line 40 & 44 in script must be replaced by one alert onSubmit)

11-07-2013, 09:45 AM
The easiest thing would be to edit the script to make both alert texts read the same. Using a text only editor like NotePad, open up the file. Instead of trying to change the logic, simply change both:

De tekst is te breed voor de geselecteerde breedte.


De tekst is te smal voor de geselecteerde breedte.


Bewerk tekst invoeren

(Or that in better Dutch. I used Google Translate to get that. It doesn't always give the best translation or syntax.)

11-07-2013, 10:28 AM
OK ... that is my goal.

But how can I change the script to do it that way ?

11-07-2013, 01:46 PM
Use NotePad.

11-07-2013, 01:59 PM
I'am working with Dreamweaver, so I can edit the script there.

But I don't know how I must change the script hitself.
Now the popups appear when inputted text is too large or too small, without submitting the page.
I only want the popup appear when submitting, clicking on "Add to shoppingcart" (green button : in wikelwagen).

I hope you understand me. :o

11-07-2013, 02:44 PM
Yes, I think I do now and I was wondering before if I did or not, I didn't. I will have a closer look at it. You could probably get rid of that entire script and use a form validation script instead. That's what you want, right, no alerts or reminders until the form is submitted?

11-08-2013, 08:44 AM
Yes, no alerts until submit the form, except for the warning tekst after the dimension.

You could probably get rid of that entire script

The script is used to mesure the text.

When the text is less then 1,3 mm or more then 58 cm (hight), a warningtext appears with after the dimension.
I think you need this for the alert on submit ?

11-10-2013, 03:34 AM
Je kan detecteren de hoogte van de tekst, maar u kunt de hoogte van het beeld te detecteren zoals zo

was _URL = venster.URL || venster.webkitURL;
$("#afvijlen").wijziging(functie (en) {
was afvijlen, img;
if ((afvijlen = deze.afvijlens[0])) {
img = new afbeelding();
img.onload = functie () {
alert(deze.breedte + " " + deze.hoogte);
img.src = _URL.createvoorwerpURL(afvijlen);


(in het Engels)

You cant detect the height of text, but you can detect the height of an image like so

var _URL = window.URL || window.webkitURL;
$("#file").change(function (e) {
var file, img;
if ((file = this.files[0])) {
img = new Image();
img.onload = function () {
alert(this.width + " " + this.height);
img.src = _URL.createObjectURL(file);

Also anyone else reading this in English, Yammaski wants an alert to pop up when the text gets too big using a dropdown. So like if one option is to have the text at 12em another at 15em and one at 20em, an alert would show up at 20em because that text is too big. It is really hard for me to put my ideas down on this post, let alone to program the javascript, but I hope I can try to help.

11-10-2013, 10:13 AM
So it's impossible to add the alert (on submit the page) to the script ?

11-10-2013, 01:17 PM
No one said that. And I didn't mean to throw away the other code. I guess I did say that. I meant not to use it for the alert at that point. You will probably want to keep some of the code because it's used to determine if the values are within the acceptable ranges. I also said you might want to use a validation script instead. You're already using jQuery on the page. So look into:


I would add as well that maybe you don't need an alert on submit. As long as error messages appear in the form itself, pointing the way for resolving the problem(s), all you really need is for it not to submit.

11-12-2013, 11:22 AM
solved :)