Jquery: alert() when submit with default value

Posted on 2009-04-20
Last Modified: 2012-06-27
how to put jquery script with message to change the default value for user (to the script below):

alert ("helloworld");
<% if $display == 1 OR $_URL == $URL %>


	<script type="text/javascript">$(document).ready(function(){$("#bc").bind("change",function(){if(this.value=="1"){$("#c").attr("disabled",true)}else{$("#c").attr("disabled",false)}});$("#bc").change()});</script>

	<div id=search_form class='clear rel pad-left1 window<% if $display_show == '' %> none<% /if %>'>

	<form action=<% $URL %>catalogs/ method=GET name=searchform>

		<script>jQuery(function($){$("#t").Watermark("search\u00A0<% include file = $TPLx.'bl/if_search/index2.html' %>","#ccc")});</script>

			<input type=text name=t id=t size=54 />

			<% if $_URL == $URL %>

		  <select name=bc id=bc class=cc>

		  	<option value=''>&ndash;&nbsp;Select Category&nbsp;&ndash;</option>

		  	<% foreach from = $bc key = k  item = v %><option value=<% $bc[$k][id] %><% if $GET[bc] == $bc[$k][id] %> selected<% /if %>><% $bc[$k][t] %></option><% /foreach %>


		  <% /if %>


			<select name=c id=c class=ccc<% if $_GET[0] == 'catalogs' OR $_GET[0] == '' %><% else %> disabled<% /if %>>

				<option value=''>&ndash; <% if $_GET[0] == 'catalogs' OR $_GET[0] == '' %><% else %>All&nbsp;<% /if %><% include file = $TPLx.'bl/if_search/index.html' %>&nbsp;&ndash;</option>

				<% foreach from = $c  key = k  item = v %><option value=<% $c[$k][id] %><% if $GET[c] == $c[$k][id] %> selected<% /if %>><% $c[$k][t] %></option><% /foreach %>


			<a href=# onclick=document.searchform.submit(); class='fg-button button-small ui-state-default fg-button-icon-right ui-corner-all'>search</a>&nbsp; <a href=#>advanced search</a><br />

			<span class='bold'>Your recent searches:</span>&nbsp; <span class=dsc>none</span> <a href=#>AA</a>, <a href=#>ethanol</a>



	<% /if %>

Open in new window

Question by:AndyPSV
    LVL 10

    Accepted Solution

    Store the defaults in a javascript array. Then onsubmit test each input against its default value until you get a mismatch. At that point alert the user and return false.

    Is that what you're wanting to do?

    Author Comment

    Yes, could you give me the javascript code?

    Author Closing Comment

    answer not needed, thanks btw

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question ( on how to make a page show some balloons animate up a page…
    Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now