Explain how to validate website address using JavaScript? User should not be allowed to enter special characters except hyphen(-)?
Submitted by: Administratorfunction ValidateWebAddress(field,alerttext)
{
with(field)
{
var companyUrl =value;
var RegExp = /^(([w]+:)?//)?(([dw]|%[a-fA-fd]{2,2})+(:([dw]|%[a-fA-fd]{2,2})+)?@)?([dw][-dw]{0,253}[dw].)+[w]{2,4}(:[d]+)?(/([-+_~.dw]|%[a-fA-fd]{2,2})*)*(?(&?([-+_~.dw]|%[a-fA-fd]{2,2})=?)*)?(#([-+_~.dw]|%[a-fA-fd]{2,2})*)?$/;
i f(RegExp.test(companyUrl)) {
return true;
}
else
{
alert(alerttext);
return false;
}
}
}
Call this fuction in an if else structure
Pass the field name and an alert string
if(validate_r(website,"Need to specify your site")==false)
{
return false;
}
Submitted by: Administrator
{
with(field)
{
var companyUrl =value;
var RegExp = /^(([w]+:)?//)?(([dw]|%[a-fA-fd]{2,2})+(:([dw]|%[a-fA-fd]{2,2})+)?@)?([dw][-dw]{0,253}[dw].)+[w]{2,4}(:[d]+)?(/([-+_~.dw]|%[a-fA-fd]{2,2})*)*(?(&?([-+_~.dw]|%[a-fA-fd]{2,2})=?)*)?(#([-+_~.dw]|%[a-fA-fd]{2,2})*)?$/;
i f(RegExp.test(companyUrl)) {
return true;
}
else
{
alert(alerttext);
return false;
}
}
}
Call this fuction in an if else structure
Pass the field name and an alert string
if(validate_r(website,"Need to specify your site")==false)
{
return false;
}
Submitted by: Administrator
Read Online Scripting Job Interview Questions And Answers
Top Scripting Questions
☺ | How to disable back button in Mozilla? |
☺ | Explain how to execute WScript & WSH object? How will i create WSH objects? |
☺ | Explain how to fetch two values from database into two variables in shell scripting? |
☺ | How to disconnect the vpn client in VB Script? |
Top Scripting language Categories
☺ | AngularJS Interview Questions. |
☺ | Ext-JS Interview Questions. |
☺ | Dojo Interview Questions. |
☺ | Expert Developer JavaScript Interview Questions. |
☺ | jQuery Mobile Interview Questions. |