Hello ,
I am working in javascript and i want to validate some field.
If condtion fail then return to main page?
Please define how to return main page if validation fail in javascript?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abrar Ahmad AnsariPosted Apr 23, 2015, 6:41 AM
suppose you have defined your function
function formvalue()
{
var MyForm=get myfrom ;
return checkValues(MyForm);
}
Davin MartynPosted Apr 20, 2015, 8:18 AM
Abrar Ahmad AnsariPosted Apr 20, 2015, 7:25 AM
//use below code.
function checkValues(MyForm) {
var e1 = document.getElementById("<%=txtEmail.ClientID%>").value;
var e2 = document.getElementByI("<%=txtDISPLAY.ClientID%>").value;
if (e1 == "" || e2 == "") {
alert('Return value of gEBI: ' + e2.value);
window.location.href = 'LetterWorksheet.asp';
}
else {
return true;
}
}
Davin MartynPosted Apr 20, 2015, 7:06 AM
{
var e1 = document.getElementById('txtEmail');
var e2 = document.getElementById('txtDISPLAY');
if(e1 ==null)
{
alert('Return value of gEBI: ' + e2.value);
window.location.href ='LetterWorksheet.asp';
}
else
{
return true;
}
} this is my function but this is redirect next page
Abrar Ahmad AnsariPosted Apr 20, 2015, 6:46 AM
var obj = null;
if(obj== null)
{
alert ("");//some message
window.location.href = 'mainpage.asp';
}
else { return true; }
Davin MartynPosted Apr 20, 2015, 6:38 AM
if(var== null)
{
alert ("");//some message
window.location.href = 'mainpage.asp';
} else
{
return true;
}
}
this is right or wrong
Abrar Ahmad AnsariPosted Apr 20, 2015, 6:09 AM