Displat An Alert When Field Box Is Empty Or With Certain Value?
Sep 15, 2009
I'm trying to get this code to work correctly. What I want it to do is to place a value in the field box then when the curser clicks there the field becomes blank.Ok, that part works.But I want it to display an alert if the submit button is clicked while the value is being displayed.Also, i want it to display an alert if the field has become blank and the submit button has been clicked.
I have been working on this for a month now as an exercise (I am a beginner) and I am still having problems. Every time I get a user to fully validate all information I keep getting an empty alert box. Why is it showing up empty and not with a total amount? Im 95% sure my code is correct.
Code:
<html> <head> <script language="javascript" type="text/javascript"> //function to show province
that a javascript which is validating a phone number accepts only digits but if the text field is left empty it should accept the entry as an empty entry...
this.add = function(element, err) { if ( !('__validate' in form[element]) ) { form[element].__validate = function() { if (this.value=='') { alert(err); this.focus(); return false; } }
} fields.push(form[element]); }
this.check = function() { var len = fields.length; for (var i=0; i<len; i++) if ( !fields[i].__validate() ) return false;
return true; } }
function form_onsubmit(form) { var vform = new Validate_form(form); vform.add('domain_name', 'The domain field is empty'); return(vform.check()); } --></script> <form name="signup" method="post" action="" onsubmit="return form_onsubmit();"> <input type="text" name="domain_name" /> <input type="submit" /> </form>
This is nothing special. just a basic empty field validator. it's probably not as efficient as it could be because it assigns the function to the various elements. It also only supports text fields. I was thinking of allowing a 3rd argument on Validate_form.add to accept something like Validate_form.stock.email/number/etc (functions). ah well..
I have disabled a file input field which has a textbox above it. I am trying to make it so that when there is text in the textbox the file field is enabled and disabled when it is emtpy.
I do not want to assign id's to the file inputs so im trying to use the current[code]...
I want to test if a input field is empty or not, if it is I don't want to execute the rest of the script. After googling I thought I might of found a solution but it doesn't appear to be working :( Even if the input field is empty my script still executes.The solution I found How do I test whether an element exists?The only thing I really add was:
if ($('#phone').length) before $('#search_customer').blur(function() to test the input field add_reservation.php
I have a form and in the form is a checkbox use as a switch to hide and unhide a two textbox. When the other textbox is hide, the other is unhide such as the code below. When the user click the submit button on the first time and there is an error, it reloads and the id="fieldset.-in_honor" hide because it is set to hide initially but not empty. My problem is, I want to show the fieldset whichever is not empty after submit button is click and there is an error so user will not enter any more information to the other field. Is that possible?
/*toggle switch*/ <p><input type="checkbox" name="in_honor" value="" id="checkmemoriam" onclick="showHide(this.name);" />Please check to make this donation in honor of someone special.</p> /*hide textbox but unhide when the switch is on or the checbox is check*/ <fieldset id="fieldset-in_honor" class="fieldgroup" style="display:none"> <legend class="hide">In Honor Of</legend> <p>To make this donation in honor of someone special, please complete the two fields below:</p> <div class="formfield" <?php echo highlight('donate_honor_name'); ?>> <label for="donate_honor_name">Name:</label> <input id="donate_honor_name" name="donate_honor_name" class="text" type="text" value="<?php safeEcho($form['donate_honor_name'])?>" /> <?php helper_error('donate_honor_name'); ?> </div> <div class="formfield" <?php echo highlight('donate_honor_acknowledgement'); ?>> <label for="donate_honor_acknowledgement">Acknowledgement should be sent to:</label> <textarea id="donate_honor_acknowledgement" name="donate_honor_acknowledgement"><?php safeEcho($form['donate_honor_acknowledgement'])?>
I have a problem in asp application validation. My textbox only accepts numeric value.It should not accept empty field and negative values and charcters.I am not aware of IsNan function.
The thickbox opens with the title "Preview", but is empty.I've alerted the div after setting it, and it does contain the formfield value.Why might this be happening? I've also tried setting the div like this (foo as dummy text - to no avail):
I found the precursor of this script online, I modified a few small things, I ran the results through jslint, I fixed the apparent errors, and then I formatted it. This is what I came up with:
function clearText(thefield){ if (thefield.defaultValue == thefield.value){ thefield.value = ""; } } function echeck(str){ [Code]....
I want to do a form validation and it should return a message like "should not be empty" when the user leaves the field blank..
I have html code like this
Now I want to know how can i display alert message to the user saying that the particular label name should not be empty..
For eg.. here I want to display alert as "Did you find this article useful? field should not be empty".... (Assuming this is mandatory)
I have so many fields like this in my form(checkbox, radio buttons, etc...) and i want to display alert with label name...
How can I do this using javascript.. (I know how to do validation in javascript popping up the alert(without label name), But I am not sure how to display alert with label name))))
Code: <script language="JavaScript"> var checkobj function agreesubmit(el){[code]....
i need to make it like if the button is clicked and there the agreement checkbox is not checked.. it should give an alert that the alert is not checked.. i know that would require a if and else statement but i cant figure out how to do it
i am facing a problem after using jquery jconfirm alert. Issue is that after receiving confirm alert, when user press tab to go on Cancel button and press Enter key there, despite of firing event of Cancel button, it fires the event of OK button. this issue is not produced when user press the cancel button by mouse. Waiting for your replies.
php page is echoing out:{"species":"Please select a species!"} I double checked the response from the php and firebug shows the same. On success alert is not alerting the JSON data instead, I'm receiving [object Object]. Why is that and how do what should I do to fix this?
I'm currently working on MySQL/PHP/JavaScript project using AJAX. I came across some weird abnormality .for some reason alert(textarea2); shows nothing but if I place another alert(textarea2); right after the first one it works, second pop-up contains responseText....also I've tried alert(resp.responseText); it worked fine,
new Ajax.Request("categories-inset.php", { method: 'get', [code]....
I am building a registration page . If the user completes all the required field i load the info into the database but if there are missing fields I combined some javascript into php to display next to the empty field a note that it should be filled. This is my code...
I'm trying, to fill a table with data I receive from a Servlet. In Chrome everything works fine. But when I try the app on IE the responseText is allways empty. The following is my JS code (using prototype):
function updateToDeleteTable(){ var url = 'getDefHidConFechaInsercionMayor?plantacion_id='+$('plantacion_id'). options[$('plantacion_id').selectedIndex].value + "&fechaDesde="+$("dateSelect").options[$("dateSelect").selectedIndex].value;
[Code].....
I know the servlet returns a correct text, because when I enter the request uri in a new IE tab it returns the appropiate html code.
Allso when I check the variable response in the IE JS debugger the resaponse of the servlet is 200 (OK). I realy can't think of anything I'm doing wrong, exept, that maybe there is a size limit for the responseText.
Two ajax and php files are located in a domain. and, ajax is calling in another domain. Why get a response from php is empty? While not empty. Like the image attached.