top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Can someone please provide easiest way to form validation?

0 votes
324 views
Can someone please provide easiest way to form validation?
posted Sep 5, 2014 by Amit Kumar Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

You need to do something like this

<form id="myform" action="myprocess.php" method="post" onsubmit="return validate();">
<input type="submit" value="Submit this form" />
</form>

<script type="text/javascript">
function validate(){
    // check the validity of the code here 
    if(!valid)
    {
        alert('Error');
        return false;
    }
    return true;
}
</script>
answer Sep 5, 2014 by Salil Agrawal
Similar Questions
+1 vote

I have a web application written in PHP. It have been running for several years. Now I want to run it as a stand-alone application on an Android smartphone or tablet. How can I do it?

+3 votes

My form is somewhat like this:-

 <form id="form1" method="post" name="form1">
 //...fields like firstname, email......
 <button type="submit" id="submit" name="submit" onclick="validate(this)">SUBMIT</button>
 < /form>

The javascript validate function:-

function validate(ref)
{
    if(document.form1.firstname.value=="")
    {
            window.alert("First Name Cannot be Blank");
            return;
    }

    // validating other fields like email... If any field is invalid return 
    document.form1.action="response"
    document.form1.submit()
} 

Now what the problem is suppose I left the firstname field blank and click submit button then windows alerts that firstname field is mandatory....and as soon as I click the OK button in alert form the form is posted...

Now question is that I assign the action attribute after validating all the fields and if any one is invalid the function returns in which case action attribute of the form is not assigned then how the form is submitted.
The form should have been submitted after all the validation tests will have been successful and controls would have reached document.form1.submit(). And what is the solution for this.

I am using Python Flask and rendering template using jinja2.

+1 vote

I need to access ClearQuest programatically using Perl. I just found ClearQuest OSLC REST API. Client is planning to use ClearQuest web 7.1.1. I read that it comes with OSLC REST API out the box.
Can someone please provide me some examples on how I can access the CQ through Perl using this API.

...