Forums

ASP

This topic is locked

ASP registration?

Posted 25 Sep 2007 19:02:37
1
has voted
25 Sep 2007 19:02:37 Seng Seng posted:
Hi guys, this is my first time here... and I have a urgent question to ask regarding about my website project.

I'm trying to create a asp-databased registration page with validation checker.
I only have 3 fields for registration: Username, Password, and E-mail.

I've tried using javascript validation but whenever the pop-up box appears and is being clicked, I will be re-directed elsewhere. What I really want is the page to stay and to indicate the errors (like "Username is not entered".
If not, like how this website's registration page is done.

Can someone please guide me on this one? I really need it to be solved...

Replies

Replied 26 Sep 2007 10:04:41
26 Sep 2007 10:04:41 Georgi Kralev replied:
Hi Seng,

To cancel the submit when the validation does not pass you just have to return false at onsubmit of the form.

For example check the following sample code:
<i>
&lt;script type="text/javascript"&gt;
function validate(vform)
{ //Some validation
if (vform.textfield.value==null||vform.textfield.value==""
{
//Does not pass the validation
alert("The Text filed is required!";
<b>return false;</b>
}

//Pass the validation
<b>return true;</b>
}
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form name="form1" method="post" action="register.asp" onsubmit="<b>return validate(this)</b>"&gt;
&lt;input type="text" name="textfield" id="textfield"&gt;
&lt;input type="submit" name="button" id="button" value="Submit"&gt;
&lt;/form&gt;
</i>
In the above sample code onSubmit of the form is executed the validation function.
If the form is valid (it is set value to textfield input filed) it return true and it is called the register.asp.
If the form is not valid (textfield is empty) it is alerted message and the submit is stopped
(The user cannot submit the form until he enter value for the textfield).

I hope this helps you.

Regards,

Georgi Kralev

----------------------------------
Support - www.DMXzone.com
Replied 27 Sep 2007 20:03:50
27 Sep 2007 20:03:50 Seng Seng replied:
YEAH! It did helped! Thanks alot!

But some of your javascript lines are wrong but I managed to solve it as I have very very basic knowledge in it.

But anyway, really thanks alot! You saved my as*!


Cheers,
Seng

Reply to this topic