php - Redirect the Page after Form is Submitted - Javascript


Q1. How could I place a code that can redirect the page after the form submitted??

Q2. I am looking some article aboutreturn value, anyone please recommend some good article for me.

    <form method="post" name="formName">
    <input type="text" value="Name" name="cName">
    <input type="submit" onClick="return fValidator(this)">

<script language="javascript1.8.5" type="text/javascript">

function fValidator(){
    var vName = document.formName.cName;
    var nameReg = /^[a-zA-Z]+$/;

    if (vName.value != ''){
        if (vName.value.match(nameReg)){
            alert("Your form is sumitted now!");
            return true;

        }   else{
                alert("Alphabet only!");
                return false;
    }   else{
            alert("Fill the mandatory field!");
            return false;




Use "onsubmit".

Eg:<form onsubmit="myFunction()">

This lets you to control the page behaviour after submitting the form.

People are also looking for solutions to the problem: php - javascript array Not Working properly


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.