java script
Posted: Sat Nov 14, 2009 8:09 am
<script language = "Javascript">
function Validate()
{
if (document.registration_form.name.value == '')
{
alert('Please fill in your name!');
return false;
}
if (document.registration_form.email.value == '')
{
alert('Please fill in your email address!');
return false;
}
if (document.registration_form.username.value == '')
{
alert('Please fill in your desired username!');
return false;
}
if (document.registration_form.password.value == '')
{
alert('Please fill in your desired password!');
return false;
}
if (document.registration_form.password_confirmation.value == '')
{
alert('Please fill in your password again for confirmation!');
return false;
}
if (document.registration_form.password.value !=
document.registration_form.password_confirmation.value)
{
alert("The two passwords are not identical! "+
"Please enter the same password again for confirmation");
return false;
}
if (document.registration_form.phone_number.value == '')
{
alert('Please fill in your phone number!');
return false;
}
return true;
}
</script>
Include this piece of code on your page, and change the <form> tag to trigger the execution of the Validate() function on form submit:
<form name="registration_form" method="post" action="register.php
onsubmit="return Validate();"
i am beginner in php, when i am calling above given alert script in php code it does not work between us,Please give me solution how it will work well.
Looking forward for your reply soon.
Thanks!
Regards
Sunil Gupta
function Validate()
{
if (document.registration_form.name.value == '')
{
alert('Please fill in your name!');
return false;
}
if (document.registration_form.email.value == '')
{
alert('Please fill in your email address!');
return false;
}
if (document.registration_form.username.value == '')
{
alert('Please fill in your desired username!');
return false;
}
if (document.registration_form.password.value == '')
{
alert('Please fill in your desired password!');
return false;
}
if (document.registration_form.password_confirmation.value == '')
{
alert('Please fill in your password again for confirmation!');
return false;
}
if (document.registration_form.password.value !=
document.registration_form.password_confirmation.value)
{
alert("The two passwords are not identical! "+
"Please enter the same password again for confirmation");
return false;
}
if (document.registration_form.phone_number.value == '')
{
alert('Please fill in your phone number!');
return false;
}
return true;
}
</script>
Include this piece of code on your page, and change the <form> tag to trigger the execution of the Validate() function on form submit:
<form name="registration_form" method="post" action="register.php
onsubmit="return Validate();"
i am beginner in php, when i am calling above given alert script in php code it does not work between us,Please give me solution how it will work well.
Looking forward for your reply soon.
Thanks!
Regards
Sunil Gupta