473,395 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

emptying a field

I'm wondering if I can use JS to forcibly empty a form field (sorry if
this is an FAQ - I can't find much reference to it in the group via a
quick Google search, and the one solution I did locate doesn't seem to
work).

The relevant bits of the form and script are below. The alert when the
contents of the two fields don't match DOES work, as does the focus on
the field NewPassword, but I would like if possible to empty the fields
NewPassword and NewPasswordAgain when they don't match.

<SCRIPT language="JavaScript" type="text/javascript">
<!--
function checkData()
{
var f = document.forms["new_entry"]

if(!(f.NewPassword.value == f.NewPasswordAgain.value))
{
alert("The two entries of your password didn't match.");
f.NewPassword.value == ''";
f.NewPasswordAgain.value == "'';
f.NewPassword.focus();
return false;
}
return true;
}
//-->
<FORM name="new_entry" method="GET" action="submit_company.asp"
target="_self" onSubmit="return checkData();">
<P>Choose a password of five to ten characters.</P>
<INPUT type="text" size="10" maxlength="10" class="visibletextinput"
name="NewPassword">
<BR>
<P>Re-enter password:</P>
<INPUT type="text" size="10" maxlength="10" class="visibletextinput"
name="NewPasswordAgain">
<BR><BR>
<INPUT type="submit" class="submitsmall" value="continue">
</FORM>

Apr 9 '06 #1
4 1053
Dohhhhhhhhhhhhhh! It works just fine - I was uploading the new version
of the file into the wrong FTP directory!!! Sorry about that. ;)

Apr 9 '06 #2
JRS: In article <11**********************@g10g2000cwb.googlegroups .com>
, dated Sun, 9 Apr 2006 09:21:54 remote, seen in
news:comp.lang.javascript, ba****@cix.co.uk posted :
I'm wondering if I can use JS to forcibly empty a form field (sorry if
this is an FAQ - I can't find much reference to it in the group via a
quick Google search, and the one solution I did locate doesn't seem to
work).

The relevant bits of the form and script are below. The alert when the
contents of the two fields don't match DOES work, as does the focus on
the field NewPassword, but I would like if possible to empty the fields
NewPassword and NewPasswordAgain when they don't match.

<SCRIPT language="JavaScript" type="text/javascript"> ^^^^^^^^^^^^^^^^^^^^^
Superfluous.
<!--
Not required in browsers; though could be helpful with other software.

if(!(f.NewPassword.value == f.NewPasswordAgain.value)) if( f.NewPassword.value != f.NewPasswordAgain.value ) f.NewPassword.value == ''"; ^^ ^^^

Looks wrong, twice. Copy'n'paste code for safety, don't re-type/

<P>Choose a password of five to ten characters.</P>
<INPUT type="text" size="10" maxlength="10" class="visibletextinput"

xxxx
should be password : you have more " than are necessary.


--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Apr 9 '06 #3
Dr John Stockton wrote:
[...] ba****@cix.co.uk posted :
<!--


Not required in browsers; though could be helpful with other software.


That is an understatement: the line makes use of a proprietary extension
of ECMAScript in an HTML context. In a strict ECMAScript implementation,
it would be syntactically incorrect (`<', `!', and `--' being operators)
and therefore trigger a syntax error.

In an XHTML context that is parsed by an XML parser, it is likely to
comment out the entire script, so that the script engine will never see it.
PointedEars
Apr 9 '06 #4
Thanks, John. Not sure how the superfluous quotes happened - they're
not in my text file!

wrt the INPUT type, I thought about password, but figured that - since
the possible user error here is not typing the same password twice - it
would be more useful for them if the characters were visible.

Apr 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ND | last post by:
I need to create a separate field from 4 fields, "street address", "city", "State" and "zip code". For example, Street address - 100 Forest Street City - Seattle State - WA Zip - 05555 ...
26
by: temp | last post by:
Hi, My boss is asking me to generate a column mapping report of all the queries. Basically, we get our data from ORACLE. There's a queary that create new table from ORACLE tables. Then, there...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
2
by: Brett | last post by:
My database has 2 tables: Table1 & Table2. If a field is not null on a record in table2, then the not null fields in table1 that correspond to the records in table1 needs to be updated to match the...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
13
by: Lee | last post by:
I have this function that doesn't work. I pass it the td element and an id, and it makes an input field inside the td. That part workds. What doesn't work is that I want to add an "onkeyup" on...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
6
by: Eric Lilja | last post by:
Hello, I have a the following priority_queue: priority_queue<pair<int, string pq; AFAICT, priority_queues doesn't support iterators. My question: is there a way to print its contents without...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.