Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Alter Form values before submission

Reply
Thread Tools

Alter Form values before submission

 
 
Jeremy
Guest
Posts: n/a
 
      11-17-2005
Hi All. I'm hoping I can receive some help from some kind soul. I was

flamed for asking this question elsewhere. In the example below, I have

removed references to the actual domain I'm working on, but this
doesn't change the concept.


I'm trying to create a client-side event that will run when the user
submits a form. I want them to be able to enter a value for USERID
that will either be "(E-Mail Removed)" or just "joe." the trick is
making the form accept either of them.


If the value is just "joe" don't do anything to it, and just pass it to

the server and if the value is
"(E-Mail Removed)", strip the "@domain.com" before submitting it.


Here's something that I thought might work, but didn't. Any guru that
could whip something up would be really appreciated. Thanks in
advance!


<SCRIPT TYPE="text/javascript">
<!--
// This will remove the ' @domain.com' part, (leaving just "joe")
before submitting the form.
//
function WackTheDomain()
{
if ( (USERID contains "@domain.com") )
USERID = USERID -"domain.com";
else
USERID = USERID;
}

// -->
</SCRIPT>

<FORM NAME="LOGIN" AUTOCOMPLETE="OFF" METHOD="POST"
ACTION="https://form.domain.com" onSubmit="return WackTheDomain()">


User Name <INPUT TYPE="TEXT" id ="USERID" NAME ="USERID"
VALUE=""><p>&nbsp;</p>
Password <INPUT TYPE="PASSWORD" id ="PASSWORD" NAME ="PASSWORD"
VALUE="">
<p>&nbsp;</p>
<p>


<INPUT TYPE="SUBMIT" id ="SUBMIT" NAME ="SUBMIT" alt = "Submit The
Form" >
<INPUT TYPE="HIDDEN" id ="ACTION" NAME ="ACTION" VALUE="LOGIN">


</p>
</FORM>

 
Reply With Quote
 
 
 
 
Lee
Guest
Posts: n/a
 
      11-17-2005
Jeremy said:
>
>Hi All. I'm hoping I can receive some help from some kind soul. I was
>
>flamed for asking this question elsewhere. In the example below, I have
>
>removed references to the actual domain I'm working on, but this
>doesn't change the concept.
>
>
>I'm trying to create a client-side event that will run when the user
>submits a form. I want them to be able to enter a value for USERID
>that will either be "(E-Mail Removed)" or just "joe." the trick is
>making the form accept either of them.
>
>
>If the value is just "joe" don't do anything to it, and just pass it to
>
>the server and if the value is
>"(E-Mail Removed)", strip the "@domain.com" before submitting it.
>
>
>Here's something that I thought might work, but didn't. Any guru that
>could whip something up would be really appreciated. Thanks in
>advance!
>
>
><SCRIPT TYPE="text/javascript">
><!--
>// This will remove the ' @domain.com' part, (leaving just "joe")
>before submitting the form.
>//
>function WackTheDomain()
>{
>if ( (USERID contains "@domain.com") )
>USERID = USERID -"domain.com";
>else
>USERID = USERID;
>}
>
>// -->
></SCRIPT>
>
><FORM NAME="LOGIN" AUTOCOMPLETE="OFF" METHOD="POST"
>ACTION="https://form.domain.com" onSubmit="return WackTheDomain()">
>
>
>User Name <INPUT TYPE="TEXT" id ="USERID" NAME ="USERID"
>VALUE=""><p>&nbsp;</p>
>Password <INPUT TYPE="PASSWORD" id ="PASSWORD" NAME ="PASSWORD"
>VALUE="">
><p>&nbsp;</p>
><p>
>
>
><INPUT TYPE="SUBMIT" id ="SUBMIT" NAME ="SUBMIT" alt = "Submit The
>Form" >
><INPUT TYPE="HIDDEN" id ="ACTION" NAME ="ACTION" VALUE="LOGIN">
>
>
></p>
></FORM>
>


In the future, don't try guessing about what might work.
Get rid of the <SCRIPT> block, completely.
Change your onsubmit value:

onsubmit="USERID.value=USERID.value.replace(/@domain.com/,'')"

Although it would be better to fix your server-side code so that this sort of
change happens there, instead.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alter the HTML output before it's sent to the web browser, possible? Brian Simmons ASP .Net 2 07-19-2007 08:43 PM
Alter - Perl extension for Alter Ego Objects anno4000@radom.zrz.tu-berlin.de Perl Misc 0 06-30-2007 04:13 PM
Alter Values in ListBox rn5a@rediffmail.com ASP .Net 2 01-08-2007 06:41 AM
Anyway to 'save' text from form textboxes before submission? john Javascript 0 09-09-2003 02:51 PM
Modifying form data before submission Logical Javascript 1 07-25-2003 08:58 AM



Advertisments